I am unable to get the Rocket handlebars example to work. These are my Cargo.toml dependencies:
[dependencies]
rocket = "*"
rocket_codegen = "*"
rocket_contrib = "*"
serde = "*"
serde_json = "*"
serde_derive = "*"
The errors:
error[E0432]: unresolved import `rocket_contrib::Template`
--> src\main.rs:29:5
|
29 | use rocket_contrib::Template;
| ^^^^^^^^^^^^^^^^^^^^^^^^ no `Template` in the root
error[E0599]: no method named `attach` found for type `rocket::Rocket` in the current scope
--> src\main.rs:62:10
|
62 | .attach(Template::fairing())
| ^^^^^^
The first error looks for Template
and can't find it. In the git repo of the example, it doesn't exist. How is it possible that the example works? I am sure that the Rust code in my main.rs is ok, it's the same as in the example. I think it's only a dependency problem.
I changed my Cargo.toml to:
[dependencies]
rocket = "*"
rocket_codegen = "*"
serde = "*"
serde_json = "*"
serde_derive = "*"
[dependencies.rocket_contrib]
version = "*"
features = ["handlebars_templates"]
Now I get these errors:
error[E0599]: no method named `attach` found for type `rocket::Rocket` in the current scope
--> src\main.rs:62:10
|
62 | .attach(Template::fairing())
| ^^^^^^
error[E0599]: no associated item named `fairing` found for type `rocket_contrib::Template` in the current scope
--> src\main.rs:62:17
|
62 | .attach(Template::fairing())
| ^^^^^^^^^^^^^^^^^