Struct gut::Index [−][src]
#[repr(transparent)]pub struct Index(_);
Expand description
A possibly invalid unsigned index.
The maximum usize
integer represents an invalid index.
This index type is ideal for storage.
Overflow is not handled by this type. Instead we rely on Rust’s internal overflow panics during
debug builds.
Implementations
Create a valid index from a usize type. This constructor does the necessary check for debug builds only.
Convert this Index
into Option<usize>
, which is a larger struct.
Manipulate the inner representation of the index. This method avoids the additional check
used in map
. Use this to opt out of automatic index checking.
Checked and_then
over inner index. This allows operations on valid indices only.
Apply a function to the inner usize
index. The index remains unchanged if invalid.
Apply a function to the inner usize
index.
Get the raw usize
representation of this Index. This may be useful for performance
critical code or debugging.
Trait Implementations
Performs the +=
operation. Read more
Convert the index into its underlying integer type. Panic if index is invalid.
Convert the index into its underlying integer type. In case of failure, report the given message. Read more
Map the underlying integer type. This allows restricting operations to valid indices only.
Map the underlying integer type. If the index is invalid, output the provided default.
Produce the raw inner type without checking.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Create an index from a signed integer type. If the given argument is negative, the created index will be invalid.
Create an index from a signed integer type. If the given argument is negative, the created index will be invalid.
Create an index from a signed integer type. If the given argument is negative, the created index will be invalid.
Create an index from a signed integer type. If the given argument is negative, the created index will be invalid.
Create an index from a signed integer type. If the given argument is negative, the created index will be invalid.
Create a valid index from a usize
type. This converter does the necessary bounds
check for debug builds only.
Create a valid index from a usize
type. This converter does the necessary bounds
check for debug builds only.
Create a valid index from a usize
type. This converter does the necessary bounds
check for debug builds only.
Create a valid index from a usize
type. This converter does the necessary bounds
check for debug builds only.
Create a valid index from a usize
type. This converter does the necessary bounds
check for debug builds only.
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
Auto Trait Implementations
impl RefUnwindSafe for Index
impl UnwindSafe for Index
Blanket Implementations
Mutably borrows from an owned value. Read more
impl<T> CloneBytes for T where
T: 'static + Clone,
impl<T> CloneBytes for T where
T: 'static + Clone,
pub unsafe fn clone_bytes(
src: &[MaybeUninit<u8>]
) -> Box<[MaybeUninit<u8>], Global>
pub unsafe fn clone_from_bytes(
dst: &mut [MaybeUninit<u8>],
src: &[MaybeUninit<u8>]
)
pub unsafe fn clone_into_raw_bytes(
src: &[MaybeUninit<u8>],
dst: &mut [MaybeUninit<u8>]
)
impl<T> DebugBytes for T where
T: 'static + Debug,
impl<T> DebugBytes for T where
T: 'static + Debug,
impl<T> Downcast for T where
T: Any,
impl<T> Downcast for T where
T: Any,
Convert Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
. Read more
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Convert Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read more
Convert &Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read more
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert &mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s. Read more
pub unsafe fn drop_bytes(bytes: &mut [MaybeUninit<u8>])
type Output = <I as GetIndex<'a, S>>::Output
fn at(&self, idx: I) -> Self::Output
fn at(&self, idx: I) -> Self::Output
Return a value at the given index. This is provided as the checked
version of get
that will panic if the equivalent get
call is None
,
which typically means that the given index is out of bounds. Read more
unsafe fn at_unchecked(&self, idx: I) -> Self::Output
unsafe fn at_unchecked(&self, idx: I) -> Self::Output
Return a value at the given index. This is provided as the unchecked
version of get
that has undefined behavior when the index is out of bounds. Read more
impl<T> HashBytes for T where
T: 'static + Hash,
impl<T> HashBytes for T where
T: 'static + Hash,
pub unsafe fn hash_bytes(bytes: &[MaybeUninit<u8>], state: &mut dyn Hasher)
type Output = <I as IsolateIndex<S>>::Output
pub unsafe fn isolate_unchecked(self, idx: I) -> <S as Isolate<I>>::Output
pub fn try_isolate(self, idx: I) -> Option<<S as Isolate<I>>::Output>
impl<T> PartialEqBytes for T where
T: 'static + PartialEq<T>,
impl<T> PartialEqBytes for T where
T: 'static + PartialEq<T>,
pub unsafe fn eq_bytes(a: &[MaybeUninit<u8>], b: &[MaybeUninit<u8>]) -> bool
impl<T, N> PushArrayToVec<N> for T where
T: Clone,
N: Array<T>,
impl<T, N> PushArrayToVec<N> for T where
T: Clone,
N: Array<T>,
pub fn push_to_vec(element: <N as Array<T>>::Array, set: &mut Vec<T, Global>)
pub fn push_to_vec(element: <N as Array<T>>::Array, set: &mut Vec<T, Global>)
This method tells this type how it can be pushed to a Vec
as an array.
The inverse inclusion map: attempts to construct self
from the equivalent element of its
superset. Read more
pub fn is_in_subset(&self) -> bool
pub fn is_in_subset(&self) -> bool
Checks if self
is actually part of its subset T
(and can be converted to it).
pub fn to_subset_unchecked(&self) -> SS
pub fn to_subset_unchecked(&self) -> SS
Use with care! Same as self.to_subset
but without any property checks. Always succeeds.
pub fn from_subset(element: &SS) -> SP
pub fn from_subset(element: &SS) -> SP
The inclusion map: converts self
to the equivalent element of its superset.