Struct regex_automata::util::primitives::NonMaxUsize
source · pub struct NonMaxUsize(/* private fields */);
Expand description
A usize
that can never be usize::MAX
.
This is similar to core::num::NonZeroUsize
, but instead of not permitting
a zero value, this does not permit a max value.
This is useful in certain contexts where one wants to optimize the memory
usage of things that contain match offsets. Namely, since Rust slices
are guaranteed to never have a length exceeding isize::MAX
, we can use
usize::MAX
as a sentinel to indicate that no match was found. Indeed,
types like Option<NonMaxUsize>
have exactly the same size in memory as a
usize
.
This type is defined to be repr(transparent)
for
core::num::NonZeroUsize
, which is in turn defined to be
repr(transparent)
for usize
.
Implementations§
source§impl NonMaxUsize
impl NonMaxUsize
Trait Implementations§
source§impl Clone for NonMaxUsize
impl Clone for NonMaxUsize
source§fn clone(&self) -> NonMaxUsize
fn clone(&self) -> NonMaxUsize
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for NonMaxUsize
impl Debug for NonMaxUsize
source§impl Hash for NonMaxUsize
impl Hash for NonMaxUsize
source§impl Ord for NonMaxUsize
impl Ord for NonMaxUsize
source§fn cmp(&self, other: &NonMaxUsize) -> Ordering
fn cmp(&self, other: &NonMaxUsize) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl PartialEq for NonMaxUsize
impl PartialEq for NonMaxUsize
source§fn eq(&self, other: &NonMaxUsize) -> bool
fn eq(&self, other: &NonMaxUsize) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd for NonMaxUsize
impl PartialOrd for NonMaxUsize
source§fn partial_cmp(&self, other: &NonMaxUsize) -> Option<Ordering>
fn partial_cmp(&self, other: &NonMaxUsize) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl Copy for NonMaxUsize
impl Eq for NonMaxUsize
impl StructuralEq for NonMaxUsize
impl StructuralPartialEq for NonMaxUsize
Auto Trait Implementations§
impl RefUnwindSafe for NonMaxUsize
impl Send for NonMaxUsize
impl Sync for NonMaxUsize
impl Unpin for NonMaxUsize
impl UnwindSafe for NonMaxUsize
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
Mutably borrows from an owned value. Read more