Struct rustpython_ast::source_code::OneIndexed
source · pub struct OneIndexed(/* private fields */);
Expand description
Type-safe wrapper for a value whose logical range starts at 1
, for
instance the line or column numbers in a file
Internally this is represented as a NonZeroU32
, this enables some
memory optimizations
Implementations§
source§impl OneIndexed
impl OneIndexed
sourcepub const MIN: OneIndexed = _
pub const MIN: OneIndexed = _
The smallest value that can be represented by this integer type.
sourcepub const MAX: OneIndexed = _
pub const MAX: OneIndexed = _
The largest value that can be represented by this integer type
sourcepub const fn new(value: u32) -> Option<OneIndexed>
pub const fn new(value: u32) -> Option<OneIndexed>
Creates a non-zero if the given value is not zero.
sourcepub const fn from_zero_indexed(value: u32) -> OneIndexed
pub const fn from_zero_indexed(value: u32) -> OneIndexed
Construct a new OneIndexed
from a zero-indexed value
sourcepub const fn try_from_zero_indexed(value: usize) -> Result<OneIndexed, usize>
pub const fn try_from_zero_indexed(value: usize) -> Result<OneIndexed, usize>
Construct a new OneIndexed
from a zero-indexed usize value
sourcepub const fn to_usize(self) -> usize
pub const fn to_usize(self) -> usize
Return the usize value for this OneIndexed
sourcepub const fn to_zero_indexed(self) -> u32
pub const fn to_zero_indexed(self) -> u32
Return the zero-indexed primitive value for this OneIndexed
sourcepub const fn to_zero_indexed_usize(self) -> usize
pub const fn to_zero_indexed_usize(self) -> usize
Return the zero-indexed usize value for this OneIndexed
sourcepub const fn saturating_add(self, rhs: u32) -> OneIndexed
pub const fn saturating_add(self, rhs: u32) -> OneIndexed
Saturating integer addition. Computes self + rhs
, saturating at
the numeric bounds instead of overflowing.
sourcepub const fn saturating_sub(self, rhs: u32) -> OneIndexed
pub const fn saturating_sub(self, rhs: u32) -> OneIndexed
Saturating integer subtraction. Computes self - rhs
, saturating
at the numeric bounds instead of overflowing.
Trait Implementations§
source§impl Clone for OneIndexed
impl Clone for OneIndexed
source§fn clone(&self) -> OneIndexed
fn clone(&self) -> OneIndexed
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for OneIndexed
impl Debug for OneIndexed
source§impl Display for OneIndexed
impl Display for OneIndexed
source§impl Hash for OneIndexed
impl Hash for OneIndexed
source§impl Ord for OneIndexed
impl Ord for OneIndexed
source§fn cmp(&self, other: &OneIndexed) -> Ordering
fn cmp(&self, other: &OneIndexed) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq for OneIndexed
impl PartialEq for OneIndexed
source§impl PartialOrd for OneIndexed
impl PartialOrd for OneIndexed
impl Copy for OneIndexed
impl Eq for OneIndexed
impl StructuralPartialEq for OneIndexed
Auto Trait Implementations§
impl Freeze for OneIndexed
impl RefUnwindSafe for OneIndexed
impl Send for OneIndexed
impl Sync for OneIndexed
impl Unpin for OneIndexed
impl UnwindSafe for OneIndexed
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more