Expand description
A crate that provides a simple interface to primitive ints to allow explicit widening, truncating, and sign casting.
To get started, import the prelude:
use explicit_cast::prelude::*;
assert_eq!(5u8.widen::<u16>().sign_cast().widen::<i32>().truncate::<i8>(), 5i8);§Stability
This crate is 1.0 as in being stable and or finished, as there is no other functionality to be had than
allowing explicit casting of integers. As such, a prelude has been included that imports Widen,
Truncate, and SignCast for you. No new methods will be added to these traits, and no
new traits will be added to the prelude, without a 2.0 release, that theoretically should never
happen.
Documentation updates may be published under a 1.0.X patch release, but no new functionality is planned.
Modules§
Traits§
- Sign
Cast - Trait to sign cast an integer to/from signed/unsigned
- Truncate
- Trait to truncate an integer from a larger size.
- Truncate
From - The inner trait of
Truncatethat allows it to have a generic function signature. - Widen
- Trait to widen an integer from a smaller size, either zero extending or sign extending depending on whether the integer is signed.
- Widen
From - The inner trait of
Widenthat allows it to have a generic function signature.