4 ms·
The crucial difference to Haskell is that this program: fn main() { println!("{}", 3 + 1.0); } Also fails with substantially the same error me
by twic 7y ago
The crucial difference to Haskell is that this program:
fn main() {
println!("{}", 3 + 1.0);
}
Also fails with substantially the same error message. Rust is consistent that you can't add integers to floats. Haskell's looseness around numeric literals means that it isn't.
Mind you, Rust does have that kind of looseness within the integers, so this:
fn three() -> u8 { 3 }
fn one() -> u16 { 1 }
fn main() {
println!("{}", 3 + 1);
println!("{}", 3 + one());
println!("{}", three() + 1);
println!("{}", three() + one());
}
Fails to compile only on the last println.