syn::ItemStruct 在 root 上找不到
syn::ItemStruct not found on root
我正在尝试使用 syn::ItemStruct
,但编译器告诉我:no ItemStruct in the root.
我正在使用 syn = "1.0.86"
,遵循此文档:https://docs.rs/syn/1.0.86/syn/struct.ItemStruct.html
有谁知道如何解决这个问题?
最小上下文:
fn parse(input: &ParseBuffer) -> syn::Result<Self> {
let _struct = input.parse::<Struct>()?;
let mut parsed_fields = Vec::new();
for field in _struct.span.fields {
let struct_attribute = StructField::try_from(&field)?;
parsed_fields.push(struct_attribute);
}
...
}
谢谢。
文档说:
This is supported on crate feature full
only.
这意味着您必须启用该功能:在您的 Cargo.toml
中,替换
syn = "1.0.86"
和
syn = { version = "1.0.86", features = ["full"] }
否则,syn
crate 将在没有该类型定义的情况下编译。
我正在尝试使用 syn::ItemStruct
,但编译器告诉我:no ItemStruct in the root.
我正在使用 syn = "1.0.86"
,遵循此文档:https://docs.rs/syn/1.0.86/syn/struct.ItemStruct.html
有谁知道如何解决这个问题?
最小上下文:
fn parse(input: &ParseBuffer) -> syn::Result<Self> {
let _struct = input.parse::<Struct>()?;
let mut parsed_fields = Vec::new();
for field in _struct.span.fields {
let struct_attribute = StructField::try_from(&field)?;
parsed_fields.push(struct_attribute);
}
...
}
谢谢。
文档说:
This is supported on crate feature
full
only.
这意味着您必须启用该功能:在您的 Cargo.toml
中,替换
syn = "1.0.86"
和
syn = { version = "1.0.86", features = ["full"] }
否则,syn
crate 将在没有该类型定义的情况下编译。