7

是否可以在 Rust 中包装 C 枚举?

例如C 枚举示例

4

1 回答 1

6

是的,没有任何变化(除了空格以适应流行的 Rust 风格):

enum List {
    MaxLogLevel = 1,
    MaxNumMessages,
    TrilinearFiltering,
    MaxAnisotropy,
    TexCompression,
    SRGBLinearization,
    LoadTextures,
    FastAnimation,
    ShadowMapSize,
    SampleCount,
    WireframeMode,
    DebugViewMode,
    DumpFailedShaders,
    GatherTimeStats
}

fn main() {
    println!("{} {} {}",
             MaxLogLevel as uint,
             SampleCount as uint,
             GatherTimeStats as uint);
}

打印1 10 14

于 2013-10-18T04:14:35.940 回答