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

时间:2013-10-17 17:54:52

标签: c rust

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

例如C enum example

1 个答案:

答案 0 :(得分: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