Closed
Description
From what I read of the documentation, only whole items/modules/crates can be processed through conditional compilation.
Static entities in Rust — crates, modules and items — may have attributes applied to them.
Though this is not in the documentation, this seems to work:
fn main() {
println!("{}", Blue as int);
println!("{}", Green as int);
}
enum Color {
Red = 0xff0000,
#[cfg(windows)]
Green = 0x00ff00,
Blue = 0x0000ff
}
As expected, the compiler throws an error (on Linux):
<anon>:3:20: 3:25 error: unresolved name
Green
.
However, it's not clear in the documentation what is the scope of the attribute in this instance. Have I got my idea of what is an item wrong, or is this merely an oversight in the documentation?
Metadata
Metadata
Assignees
Labels
No labels