Closed
Description
The guide gives example code (below) that doesn't compile for this reason, but does not mention deriving anywhere, and I found this confusing.
enum Ordering {
Less,
Equal,
Greater,
}
fn cmp(a: int, b: int) -> Ordering {
if a < b { Less }
else if a > b { Greater }
else { Equal }
}
fn main() {
let x = 5i;
let y = 10i;
let ordering = cmp(x, y);
if ordering == Less {
println!("less");
} else if ordering == Greater {
println!("greater");
} else if ordering == Equal {
println!("equal");
}
}
Metadata
Metadata
Assignees
Labels
No labels