Trait for Responder<'_,'_>
not satisfied
#1819
-
I am very new to Rust and I encountered this error while try to build a simple web server using Rocket. I have the following code: use rocket_contrib::json::Json;
use serde::{Serialize,Deserialize};
#[derive(Serialize,Deserialize)]
struct NotFound {
success: bool,
message: String,
}
#[get("/_/admin", format = "json")]
pub fn index() -> Json<NotFound> {
Json(NotFound {
success: false,
message: String::from("Not Found Custom 404"),
})
} On compilation, it gives me the following error: the trait bound The dependencies in my cargo.toml are as follows: [package]
name = "server"
version = "0.1.0"
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
rocket = "0.5.0-rc.1"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
[dependencies.rocket_contrib]
version = "*"
default-features = false
features = ["json"] Can somebody please help me with what mistake I am making? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
This looks like a duplicate of #1779 and a few others. Please see the CHANGELOG, especially regarding the removal of (Incidentally, |
Beta Was this translation helpful? Give feedback.
This looks like a duplicate of #1779 and a few others. Please see the CHANGELOG, especially regarding the removal of
rocket_contrib
: https://github.com/SergioBenitez/Rocket/blob/v0.5-rc/CHANGELOG.md#contrib-graduation.(Incidentally,
version = "*"
is rarely a good choice forCargo.toml
. Among other issues, it allowscargo update
to either update or downgrade that dependency on a whim, likely breaking your code that uses it.)