pub trait Truncate<T> {
// Required method
fn truncate(self) -> T;
}
Expand description
Truncating conversion between types.
Any information that doesn’t fit into the target type may be discarded. In particular:
- the sign will be discarded when converting from a signed to unsigned type
- the high bits will be discarded when converting from a larger to smaller integer type
- the fractional bits will be discarded when converting from a fractional to integer type
While this is not currently defined for non-numeric types with sensible truncations, that is within the scope of this traits purpose.