gpt4 book ai didi

rust - 如何在 Rust 的稳定版本上使用 rocket

转载 作者:行者123 更新时间:2023-12-02 16:11:15 24 4
gpt4 key购买 nike

我正在尝试使用 rustc 的稳定版本来编译 rocket web 应用程序。 rocket crate 编译正常,但我想使用来自 rocket_contrib 的静态文件服务器。我的 Cargo.toml 文件如下所示:

[dependencies]
rocket = "0.5.0-rc.1"

[dependencies.rocket_dyn_templates]
version = "0.1.0-rc.1"
features = ["handlebars"]

[dependencies.rocket_contrib]
version = "0.4.10"
default-features = false
features = ["serve"]

当我尝试运行 cargo build 时出现以下错误:

Error: Pear requires a 'dev' or 'nightly' version of rustc.
Installed version: 1.52.1 (2021-05-09)
Minimum required: 1.31.0-nightly (2018-10-05)

最佳答案

从 Rocket 的 0.5 版开始,您不需要使用 rocket_contrib,因为这个功能被拆分为已经在核心包中或移动到单独的包中的功能。来自 this revision 的注释(另请参阅 issue 1659)提供更多详细信息:

This follows the completed graduation of stable contrib features intocore, removing 'rocket_contrib' in its entirety in favor of two newcrates. These crates are versioned independently of Rocket's corelibraries, allowing upgrades to dependencies without consideration forversions in core libraries.

'rocket_dyn_templates' replaces the contrib 'templates' features. Whilelargely a 1-to-1 copy, it makes the following changes:

  • the 'tera_templates' feature is now 'tera'
  • the 'handlebars_templates' feature is now 'handlebars'
  • fails to compile if neither 'tera' nor 'handlebars' is enabled

'rocket_sync_db_pools' replaces the contrib 'database' features. Itmakes no changes to the replaced features except that the databaseattribute is properly documented at the crate root.

简而言之,您需要将您的代码从 rocket_contrib 中迁移出来。一旦 v0.5 确定发布,可能会提供更好的指南,但在那之前,您可以在 core documentation and respective Cargo feature list 中的 rocket_contrib 中寻找曾经可用的功能。 .

关于rust - 如何在 Rust 的稳定版本上使用 rocket,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67983691/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com