pub unsafe trait LengthTypewhere
Self: Copy + Sized + Eq + Ord + Add<Output = Self> + Shr<Output = Self> + Sub<Output = Self> + From<u8> + TryFrom<usize>,
usize: TryFrom<Self>,{
const MIN_VALUE: Self;
const MAX_VALUE: Self;
const ONE_VALUE: Self;
const ZERO_VALUE: Self;
// Required methods
fn as_usize(self) -> usize;
fn usize_as_self(input: usize) -> Self;
fn checked_add(self, rhs: Self) -> Option<Self>;
fn checked_sub(self, rhs: Self) -> Option<Self>;
fn wrapping_add(self, rhs: Self) -> Self;
}Expand description
This trait is used for letting you specify the type of the length and capacity fields of a flex array container, As well as indexing operations. If you have some other type that you want to use and behaves like an unsigned integer, you can implement this trait for it.
It’s marked as unsafe since your type must be continuous and ordered. under common operations such as addition multiplication like integers.
Required Associated Constants§
Sourceconst ZERO_VALUE: Self
const ZERO_VALUE: Self
The representation of 0 for this type.
Required Methods§
Sourcefn as_usize(self) -> usize
fn as_usize(self) -> usize
Converts this type to a usize. This will only
be called when the value by FlexArr`` if the same value at some point successfully used usize::try_from(self)`.
An implementation could be simple as:
Self as usize
Sourcefn usize_as_self(input: usize) -> Self
fn usize_as_self(input: usize) -> Self
Converts a usize to this type. This will only
be called when the value by FlexArr`` if the value at some point successfully used Self::try_from(input)`
was a successful conversion.
Sourcefn checked_add(self, rhs: Self) -> Option<Self>
fn checked_add(self, rhs: Self) -> Option<Self>
The same as checked_add for rust’s built in types.
Sourcefn checked_sub(self, rhs: Self) -> Option<Self>
fn checked_sub(self, rhs: Self) -> Option<Self>
The same as checked_sub for rust’s built in types.
Sourcefn wrapping_add(self, rhs: Self) -> Self
fn wrapping_add(self, rhs: Self) -> Self
The same as wrapping_add for rust’s built in types.
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.