构建 Rocket handlebars 示例时未解决的导入模板
Unresolved import Template when building Rocket handlebars example
我无法获得火箭 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 中的 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())
| ^^^^^^^^^^^^^^^^^
您缺少 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"]
我无法获得火箭 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 中的 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())
| ^^^^^^^^^^^^^^^^^
您缺少 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"]