Struct rustpython_parser::source_code::OneIndexed
pub struct OneIndexed(_);
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§
§impl OneIndexed
impl OneIndexed
pub const MIN: OneIndexed = unwrap(Self::new(1))
pub const MIN: OneIndexed = unwrap(Self::new(1))
The smallest value that can be represented by this integer type.
pub const MAX: OneIndexed = unwrap(Self::new(u32::MAX))
pub const MAX: OneIndexed = unwrap(Self::new(u32::MAX))
The largest value that can be represented by this integer type
pub 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.
pub 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
pub 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
pub const fn to_usize(self) -> usize
pub const fn to_usize(self) -> usize
Return the usize value for this OneIndexed
pub const fn to_zero_indexed(self) -> u32
pub const fn to_zero_indexed(self) -> u32
Return the zero-indexed primitive value for this OneIndexed
pub 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
pub 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.
pub 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§
§impl Clone for OneIndexed
impl Clone for OneIndexed
§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 more§impl Debug for OneIndexed
impl Debug for OneIndexed
§impl Display for OneIndexed
impl Display for OneIndexed
§impl Hash for OneIndexed
impl Hash for OneIndexed
§impl Ord for OneIndexed
impl Ord for OneIndexed
§impl PartialEq<OneIndexed> for OneIndexed
impl PartialEq<OneIndexed> for OneIndexed
§fn eq(&self, other: &OneIndexed) -> bool
fn eq(&self, other: &OneIndexed) -> bool
self
and other
values to be equal, and is used
by ==
.§impl PartialOrd<OneIndexed> for OneIndexed
impl PartialOrd<OneIndexed> for OneIndexed
§fn partial_cmp(&self, other: &OneIndexed) -> Option<Ordering>
fn partial_cmp(&self, other: &OneIndexed) -> Option<Ordering>
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 more