Struct Rust 中的字段数

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

我正在使用结构的结构如下:

       GC{ 
            v: "1.0.0", 
            e: "xx", 
            d: "xx/xx/xx", 
            gc: [S{ 
                    S: [A{ 
                           n: [N { 
                                   v: "S" 
                                  }
                               ], 
                           f: [M{ 
                                    v: "P" 
                                   }
                               ] 

... }

我想计算字段 A 并且我使用了 field_count()。 如果我尝试写:

    let  fileconf_vec_S =  fileconf.gc;
    let fileconf_s = &fileconf_vec_S[0];
    println!("{:?}", fileconf_s::field_count);

它返回我“无法解决:使用未声明的板条箱或模块

fileconf_s
使用未声明的板条箱或模块
fileconf_s
rustcClick for full compiler diagnostic"
我怎样才能扩展 S 结构的特征?

rust struct custom-fields
© www.soinside.com 2019 - 2024. All rights reserved.