Trait mutils::internal::FromClamped [−][src]
It's useful to convert from a higher precision numerical type, to a lower one. i.e. u64 to u32.
When this happens you can lose data. There are multiple ways to deal with this. One approach is to clamp within the target range.
This isn't just about moving to the same type with less bits. It's for any change where you end up with less data. Such as moving between signed and unsigned. i.e. i32 -> u32, and u32 -> i32.
Required methods
fn from_clamped(n: N) -> Self
[src]
Returns the value in the new type, but clamped.