我无法让火箭handlebars example工作。这是我的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锈代码是好的,这是相同的例子。我认为这只是一个依赖的问题。
我改变了我的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())
| ^^^^^^^^^^^^^^^^^
这是因为丢失了handlebars_templates
功能。您可以see this in the example's Cargo.toml
:
[dependencies.rocket_contrib]
version = "*" # Not a good idea to use * as version
features = ["handlebars_templates"]