pub trait Tbits {
// Required method
fn tbits() -> u32;
}Available on crate feature
bits only.Expand description
Generic trait for define the size of the integers type in bits.
§Usage
Basic use of the trait.
use num_convert::Tbits;
assert_eq!(i8::tbits(), 8_u32);
assert_eq!(u64::tbits(), 64_u32);§Examples
fn get_bits_from_type<T: Tbits>(value: T) -> u32 {
T::tbits()
}
assert_eq!(get_bits_from_type(-128_i8), 8_u32);
assert_eq!(get_bits_from_type(isize::MIN), 64_u32);Required Methods§
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.