无法使用 Syn 中的“parse_file”功能,如何在 Rust 中启用“parsing”属性

问题描述 投票:0回答:1

我正在尝试使用

syn::parse_file
板条箱中的
syn
功能。

但是,我无法使用它,并在板条箱中找到了一个带有

feature
属性的函数:

#[cfg(all(feature = "parsing", feature = "full"))] 
#[cfg_attr(doc_cfg, doc(cfg(all(feature = "parsing", feature = "full"))))]
pub fn parse_file(mut content: &str) -> Result<File> {
    // other code
}

找不到此功能的任何说明。
如何在我的项目中启用这些功能?
并使用这个功能。

rust attributes syn
1个回答
1
投票

您可以在

Cargo.toml
文件中启用特定的 crate 功能 - 您可以在其中指定 crate 本身及其版本。

对于 syn 箱,

parsing
功能默认启用,但
full
未启用,如文档中所述。

在这里您可以阅读有关如何为您的板条箱(依赖项)启用功能的更多信息。

© www.soinside.com 2019 - 2024. All rights reserved.