pub struct Index(/* private fields */);
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§
source§impl Index
impl Index
sourcepub fn new(i: usize) -> Index
pub fn new(i: usize) -> Index
Create a valid index from a usize type. This constructor does the necessary check for debug builds only.
sourcepub fn into_option(self) -> Option<usize>
pub fn into_option(self) -> Option<usize>
Convert this Index
into Option<usize>
, which is a larger struct.
sourcepub fn map_inner<F: FnOnce(usize) -> usize>(self, f: F) -> Index
pub fn map_inner<F: FnOnce(usize) -> usize>(self, f: F) -> Index
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.
sourcepub fn and_then<F: FnOnce(usize) -> Index>(self, f: F) -> Index
pub fn and_then<F: FnOnce(usize) -> Index>(self, f: F) -> Index
Checked and_then
over inner index. This allows operations on valid indices only.
sourcepub fn apply<F: FnOnce(&mut usize)>(&mut self, f: F)
pub fn apply<F: FnOnce(&mut usize)>(&mut self, f: F)
Apply a function to the inner usize
index. The index remains unchanged if invalid.
sourcepub fn into_inner(self) -> usize
pub fn into_inner(self) -> usize
Get the raw usize
representation of this Index. This may be useful for performance
critical code or debugging.
Trait Implementations§
source§impl AddAssign<usize> for Index
impl AddAssign<usize> for Index
source§fn add_assign(&mut self, rhs: usize)
fn add_assign(&mut self, rhs: usize)
+=
operation. Read moresource§impl CheckedIndex<usize> for Index
impl CheckedIndex<usize> for Index
source§fn unwrap(self) -> usize
fn unwrap(self) -> usize
source§fn expect(self, msg: &str) -> usize
fn expect(self, msg: &str) -> usize
source§fn map<F: FnOnce(usize) -> usize>(self, f: F) -> Index
fn map<F: FnOnce(usize) -> usize>(self, f: F) -> Index
source§fn map_or<U, F: FnOnce(usize) -> U>(self, default: U, f: F) -> U
fn map_or<U, F: FnOnce(usize) -> U>(self, default: U, f: F) -> U
source§fn into_inner(self) -> usize
fn into_inner(self) -> usize
source§impl From<CellEdgeIndex> for Index
impl From<CellEdgeIndex> for Index
source§fn from(i: CellEdgeIndex) -> Self
fn from(i: CellEdgeIndex) -> Self
source§impl From<CellFaceIndex> for Index
impl From<CellFaceIndex> for Index
source§fn from(i: CellFaceIndex) -> Self
fn from(i: CellFaceIndex) -> Self
source§impl From<CellVertexIndex> for Index
impl From<CellVertexIndex> for Index
source§fn from(i: CellVertexIndex) -> Self
fn from(i: CellVertexIndex) -> Self
source§impl From<EdgeCellIndex> for Index
impl From<EdgeCellIndex> for Index
source§fn from(i: EdgeCellIndex) -> Self
fn from(i: EdgeCellIndex) -> Self
source§impl From<EdgeFaceIndex> for Index
impl From<EdgeFaceIndex> for Index
source§fn from(i: EdgeFaceIndex) -> Self
fn from(i: EdgeFaceIndex) -> Self
source§impl From<EdgeVertexIndex> for Index
impl From<EdgeVertexIndex> for Index
source§fn from(i: EdgeVertexIndex) -> Self
fn from(i: EdgeVertexIndex) -> Self
source§impl From<FaceCellIndex> for Index
impl From<FaceCellIndex> for Index
source§fn from(i: FaceCellIndex) -> Self
fn from(i: FaceCellIndex) -> Self
source§impl From<FaceEdgeIndex> for Index
impl From<FaceEdgeIndex> for Index
source§fn from(i: FaceEdgeIndex) -> Self
fn from(i: FaceEdgeIndex) -> Self
source§impl From<FaceVertexIndex> for Index
impl From<FaceVertexIndex> for Index
source§fn from(i: FaceVertexIndex) -> Self
fn from(i: FaceVertexIndex) -> Self
source§impl From<Index> for CellEdgeIndex
impl From<Index> for CellEdgeIndex
source§impl From<Index> for CellFaceIndex
impl From<Index> for CellFaceIndex
source§impl From<Index> for CellVertexIndex
impl From<Index> for CellVertexIndex
source§impl From<Index> for EdgeCellIndex
impl From<Index> for EdgeCellIndex
source§impl From<Index> for EdgeFaceIndex
impl From<Index> for EdgeFaceIndex
source§impl From<Index> for EdgeVertexIndex
impl From<Index> for EdgeVertexIndex
source§impl From<Index> for FaceCellIndex
impl From<Index> for FaceCellIndex
source§impl From<Index> for FaceEdgeIndex
impl From<Index> for FaceEdgeIndex
source§impl From<Index> for FaceVertexIndex
impl From<Index> for FaceVertexIndex
source§impl From<Index> for VertexCellIndex
impl From<Index> for VertexCellIndex
source§impl From<Index> for VertexEdgeIndex
impl From<Index> for VertexEdgeIndex
source§impl From<Index> for VertexFaceIndex
impl From<Index> for VertexFaceIndex
source§impl From<Index> for VertexIndex
impl From<Index> for VertexIndex
source§impl From<Option<CellEdgeIndex>> for Index
impl From<Option<CellEdgeIndex>> for Index
source§fn from(mb_i: Option<CellEdgeIndex>) -> Self
fn from(mb_i: Option<CellEdgeIndex>) -> Self
source§impl From<Option<CellFaceIndex>> for Index
impl From<Option<CellFaceIndex>> for Index
source§fn from(mb_i: Option<CellFaceIndex>) -> Self
fn from(mb_i: Option<CellFaceIndex>) -> Self
source§impl From<Option<CellVertexIndex>> for Index
impl From<Option<CellVertexIndex>> for Index
source§fn from(mb_i: Option<CellVertexIndex>) -> Self
fn from(mb_i: Option<CellVertexIndex>) -> Self
source§impl From<Option<EdgeCellIndex>> for Index
impl From<Option<EdgeCellIndex>> for Index
source§fn from(mb_i: Option<EdgeCellIndex>) -> Self
fn from(mb_i: Option<EdgeCellIndex>) -> Self
source§impl From<Option<EdgeFaceIndex>> for Index
impl From<Option<EdgeFaceIndex>> for Index
source§fn from(mb_i: Option<EdgeFaceIndex>) -> Self
fn from(mb_i: Option<EdgeFaceIndex>) -> Self
source§impl From<Option<EdgeVertexIndex>> for Index
impl From<Option<EdgeVertexIndex>> for Index
source§fn from(mb_i: Option<EdgeVertexIndex>) -> Self
fn from(mb_i: Option<EdgeVertexIndex>) -> Self
source§impl From<Option<FaceCellIndex>> for Index
impl From<Option<FaceCellIndex>> for Index
source§fn from(mb_i: Option<FaceCellIndex>) -> Self
fn from(mb_i: Option<FaceCellIndex>) -> Self
source§impl From<Option<FaceEdgeIndex>> for Index
impl From<Option<FaceEdgeIndex>> for Index
source§fn from(mb_i: Option<FaceEdgeIndex>) -> Self
fn from(mb_i: Option<FaceEdgeIndex>) -> Self
source§impl From<Option<FaceVertexIndex>> for Index
impl From<Option<FaceVertexIndex>> for Index
source§fn from(mb_i: Option<FaceVertexIndex>) -> Self
fn from(mb_i: Option<FaceVertexIndex>) -> Self
source§impl From<Option<VertexCellIndex>> for Index
impl From<Option<VertexCellIndex>> for Index
source§fn from(mb_i: Option<VertexCellIndex>) -> Self
fn from(mb_i: Option<VertexCellIndex>) -> Self
source§impl From<Option<VertexEdgeIndex>> for Index
impl From<Option<VertexEdgeIndex>> for Index
source§fn from(mb_i: Option<VertexEdgeIndex>) -> Self
fn from(mb_i: Option<VertexEdgeIndex>) -> Self
source§impl From<Option<VertexFaceIndex>> for Index
impl From<Option<VertexFaceIndex>> for Index
source§fn from(mb_i: Option<VertexFaceIndex>) -> Self
fn from(mb_i: Option<VertexFaceIndex>) -> Self
source§impl From<Option<VertexIndex>> for Index
impl From<Option<VertexIndex>> for Index
source§fn from(mb_i: Option<VertexIndex>) -> Self
fn from(mb_i: Option<VertexIndex>) -> Self
source§impl From<VertexCellIndex> for Index
impl From<VertexCellIndex> for Index
source§fn from(i: VertexCellIndex) -> Self
fn from(i: VertexCellIndex) -> Self
source§impl From<VertexEdgeIndex> for Index
impl From<VertexEdgeIndex> for Index
source§fn from(i: VertexEdgeIndex) -> Self
fn from(i: VertexEdgeIndex) -> Self
source§impl From<VertexFaceIndex> for Index
impl From<VertexFaceIndex> for Index
source§fn from(i: VertexFaceIndex) -> Self
fn from(i: VertexFaceIndex) -> Self
source§impl From<VertexIndex> for Index
impl From<VertexIndex> for Index
source§fn from(i: VertexIndex) -> Self
fn from(i: VertexIndex) -> Self
source§impl From<i16> for Index
impl From<i16> for Index
Create an index from a signed integer type. If the given argument is negative, the created index will be invalid.
source§impl From<i32> for Index
impl From<i32> for Index
Create an index from a signed integer type. If the given argument is negative, the created index will be invalid.
source§impl From<i64> for Index
impl From<i64> for Index
Create an index from a signed integer type. If the given argument is negative, the created index will be invalid.
source§impl From<i8> for Index
impl From<i8> for Index
Create an index from a signed integer type. If the given argument is negative, the created index will be invalid.
source§impl From<isize> for Index
impl From<isize> for Index
Create an index from a signed integer type. If the given argument is negative, the created index will be invalid.
source§impl From<u16> for Index
impl From<u16> for Index
Create a valid index from a usize
type. This converter does the necessary bounds
check for debug builds only.
source§impl From<u32> for Index
impl From<u32> for Index
Create a valid index from a usize
type. This converter does the necessary bounds
check for debug builds only.
source§impl From<u64> for Index
impl From<u64> for Index
Create a valid index from a usize
type. This converter does the necessary bounds
check for debug builds only.
source§impl From<u8> for Index
impl From<u8> for Index
Create a valid index from a usize
type. This converter does the necessary bounds
check for debug builds only.
source§impl From<usize> for Index
impl From<usize> for Index
Create a valid index from a usize
type. This converter does the necessary bounds
check for debug builds only.
source§impl IntoIterator for Index
impl IntoIterator for Index
source§impl Ord for Index
impl Ord for Index
source§impl PartialEq<usize> for Index
impl PartialEq<usize> for Index
source§impl PartialEq for Index
impl PartialEq for Index
source§impl PartialOrd<usize> for Index
impl PartialOrd<usize> for Index
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl PartialOrd for Index
impl PartialOrd for Index
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moreimpl Copy for Index
impl Eq for Index
impl Pod for Index
impl StructuralEq for Index
impl StructuralPartialEq for Index
Auto Trait Implementations§
impl RefUnwindSafe for Index
impl Send for Index
impl Sync for Index
impl Unpin for Index
impl UnwindSafe for Index
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
§type Bits = T
type Bits = T
Self
must have the same layout as the specified Bits
except for
the possible invalid bit patterns being checked during
is_valid_bit_pattern
.source§fn is_valid_bit_pattern(_bits: &T) -> bool
fn is_valid_bit_pattern(_bits: &T) -> bool
bits
as &Self
.source§impl<T> CloneBytes for Twhere
T: Clone + 'static,
impl<T> CloneBytes for Twhere
T: Clone + 'static,
unsafe fn clone_bytes(src: &[MaybeUninit<u8>]) -> Box<[MaybeUninit<u8>]>
unsafe fn clone_from_bytes(dst: &mut [MaybeUninit<u8>], src: &[MaybeUninit<u8>])
unsafe fn clone_into_raw_bytes( src: &[MaybeUninit<u8>], dst: &mut [MaybeUninit<u8>] )
source§impl<T> DebugBytes for Twhere
T: Debug + 'static,
impl<T> DebugBytes for Twhere
T: Debug + 'static,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
source§impl<T> DropBytes for Twhere
T: 'static,
impl<T> DropBytes for Twhere
T: 'static,
unsafe fn drop_bytes(bytes: &mut [MaybeUninit<u8>])
source§impl<'a, S, I> Get<'a, I> for Swhere
I: GetIndex<'a, S>,
impl<'a, S, I> Get<'a, I> for Swhere
I: GetIndex<'a, S>,
type Output = <I as GetIndex<'a, S>>::Output
fn get(&self, idx: I) -> Option<<I as GetIndex<'a, S>>::Output>
source§fn at(&self, idx: I) -> Self::Output
fn at(&self, idx: I) -> Self::Output
get
that will panic if the equivalent get
call is None
,
which typically means that the given index is out of bounds. Read moresource§unsafe fn at_unchecked(&self, idx: I) -> Self::Output
unsafe fn at_unchecked(&self, idx: I) -> Self::Output
source§impl<T> HashBytes for Twhere
T: Hash + 'static,
impl<T> HashBytes for Twhere
T: Hash + 'static,
unsafe fn hash_bytes(bytes: &[MaybeUninit<u8>], state: &mut dyn Hasher)
source§impl<S, I> Isolate<I> for Swhere
I: IsolateIndex<S>,
impl<S, I> Isolate<I> for Swhere
I: IsolateIndex<S>,
source§impl<T> PartialEqBytes for Twhere
T: PartialEq + 'static,
impl<T> PartialEqBytes for Twhere
T: PartialEq + 'static,
unsafe fn eq_bytes(a: &[MaybeUninit<u8>], b: &[MaybeUninit<u8>]) -> bool
§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<T, N> PushArrayToVec<N> for T
impl<T, N> PushArrayToVec<N> for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.