是否可以在 Rust 中包装 C 枚举?
例如C 枚举示例
是的,没有任何变化(除了空格以适应流行的 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
。