得到,"missing `from` in implementation"

Getting, "missing `from` in implementation"

当我尝试编译代码时,我得到

error[E0046]: not all trait items implemented, missing: `from`
  --> src/api/error.rs:25:1
   |
25 | impl From<UserError> for warp::reply::Json {
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `from` in implementation
   |
   = help: implement the missing item: `fn from(_: T) -> Self { todo!() }`

我的代码很简单,

impl From<UserError> for warp::reply::Json { todo!() }

这里的问题是你需要编写或存根 From trait 的实现来编译当前,

pub trait From<T> {
    pub fn from(T) -> Self;
}

所以看起来像,

impl From<UserError> for warp::reply::Json {
  fn from(err: UserError) -> Self {
    todo!()
  }
}