October 2018
Beginner
180 pages
4h 48m
English
In all of our examples so far, when we matched DemoStruct in a pattern, we matched probability to a variable or to _. That's because probability is a floating point number, which means that two values that are functionally identical might not compare as exactly equal.
If we try to use a floating-point literal in a pattern (in Rust 1.29), we see a warning like this:

It's just a warning but, as the warning says, it's going to become an error as Rust evolves. We should treat it as an error, regardless, because the pattern will likely not work properly even though it (currently) compiles. ...
Read now
Unlock full access