我无法让 Rocket车把示例 工作。这些是我的 Cargo.toml 依赖项:
[dependencies]
rocket = "*"
rocket_codegen = "*"
rocket_contrib = "*"
serde = "*"
serde_json = "*"
serde_derive = "*"
错误:
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())
| ^^^^^^
第一个错误查找Template
并找不到它。在示例的git repo中,它不存在。这个例子怎么可能有效?我确信我的 main.rs 中的 Rust 代码是可以的,它与示例中的相同。我认为这只是一个依赖问题。
我将 Cargo.toml 更改为:
[dependencies]
rocket = "*"
rocket_codegen = "*"
serde = "*"
serde_json = "*"
serde_derive = "*"
[dependencies.rocket_contrib]
version = "*"
features = ["handlebars_templates"]
现在我得到这些错误:
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())
| ^^^^^^^^^^^^^^^^^