Trait smallnum::SmallSigned[][src]

pub trait SmallSigned {
    fn isize(&self) -> isize;
fn checked_from(num: isize) -> Self; }
Expand description

Convenience trait for signed normalization (e.g. to/from isize).

Required methods

Upcast: Get value of small signed as host register-width signed (e.g. isize)

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.

Implementations on Foreign Types

Implementors