rust 结构体的标识符在哪里?

q7solyqu  于 2023-03-02  发布在  其他
关注(0)|答案(1)|浏览(97)

https://docs.rs/syn/latest/syn/struct.DataStruct.html

pub struct DataStruct {
    pub struct_token: Struct,
    pub fields: Fields,
    pub semi_token: Option<Semi>,
}

为什么缺少已定义结构(pub ident: Ident,)的标识符?
解析struct X { ... },如何找到X

lsmepo6l

lsmepo6l1#

它在DeriveInput中,因为它被结构体、枚举和联合体共享:

pub struct DeriveInput {
    pub attrs: Vec<Attribute>,
    pub vis: Visibility,
    pub ident: Ident,
    pub generics: Generics,
    pub data: Data,
}

相关问题