Evan Carroll
Evan Carroll

Reputation: 1

Getting, "missing `from` in implementation"

When I try to compile code, I'm getting

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!() }`

My code is pretty simple,

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

Upvotes: 1

Views: 1468

Answers (1)

Evan Carroll
Evan Carroll

Reputation: 1

The problem here is you need to write or stub the implementation of the From trait to compile which is currently,

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

So that would look like,

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

Upvotes: 2

Related Questions