Closed
Description
This fails:
fn main() {
if let Some(value) = "hi".parse() {
if value <= 0.0 { println!("1") } else { println!("2") };
}
}
with the error:
error: the type of this value must be known in this context
if value <= 0.0 { println!("1") } else { println!("2") };
^~~~~
Simply flipping the order of the comparison operands allows it to compile:
fn main() {
if let Some(value) = "hi".parse() {
if 0.0 >= value { println!("1") } else { println!("2") };
}
}
Tested with rustc 1.0.0-dev (102ab57d8 2015-01-25 13:33:18 +0000)
Originally from this Stack Overflow question