pub trait SmallSigned {
// Required methods
fn isize(&self) -> isize;
fn checked_from(num: isize) -> Self;
}Expand description
Convenience trait for signed normalization (e.g. to/from isize).
Required Methods§
Sourcefn isize(&self) -> isize
fn isize(&self) -> isize
Upcast: Get value of small signed as host register-width signed (e.g. isize)
Sourcefn checked_from(num: isize) -> Self
fn checked_from(num: isize) -> Self
Downcast: Convert input isize into a primitive implementing the SmallSigned trait.
Panics if isize exceeds min/max for returned signed primitive.
core::convert::From not used b/c SmallSigned is not generic by design,
implemented only for (i8, i16, i32, i64, i128) and only up to host integer width.
§Note
Unlike others, this API has a tiny (1 comparison/branch) runtime cost.
The check in checked_from is an assert to prevent loss of precision.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.