我无法让Rocket 车把示例 工作.这些是我的Cargo.toml依赖项:
[dependencies]
rocket = "*"
rocket_codegen = "*"
rocket_contrib = "*"
serde = "*"
serde_json = "*"
serde_derive = "*"
Run Code Online (Sandbox Code Playgroud)
错误:
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())
| ^^^^^^
Run Code Online (Sandbox Code Playgroud)
第一个错误查找Template并找不到它.在该示例的git repo中,它不存在.该示例如何工作?我确信我的main.rs中的Rust代码没问题,它与示例中的相同.我认为这只是一个依赖性问题.
我将Cargo.toml更改为:
[dependencies]
rocket = "*"
rocket_codegen = "*"
serde = "*"
serde_json = "*"
serde_derive = "*"
[dependencies.rocket_contrib]
version = "*"
features = ["handlebars_templates"]
Run Code Online (Sandbox Code Playgroud)
现在我收到这些错误:
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())
| ^^^^^^^^^^^^^^^^^
Run Code Online (Sandbox Code Playgroud)
您缺少此handlebars_templates功能.您可以在示例中看到Cargo.toml:
[dependencies.rocket_contrib]
version = "*" # Not a good idea to use * as version
features = ["handlebars_templates"]
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
617 次 |
| 最近记录: |