pub struct BytePos(pub u32);Expand description
A byte offset into a source file.
This is a u32, not a usize: source files are capped at 4 GiB, and a
32-bit offset halves the storage cost of every span.
Tuple Fields§
§0: u32Implementations§
Source§impl BytePos
impl BytePos
pub const fn to_u32(self) -> u32
pub const fn to_usize(self) -> usize
Sourcepub const fn saturating_add(self, bytes: u32) -> BytePos
pub const fn saturating_add(self, bytes: u32) -> BytePos
Saturating addition. Offsets never overflow; they clamp at u32::MAX.
Sourcepub const fn saturating_sub(self, other: BytePos) -> u32
pub const fn saturating_sub(self, other: BytePos) -> u32
Difference between two offsets, clamped at zero so subtraction can never underflow or produce a negative span.
Trait Implementations§
impl Copy for BytePos
impl Eq for BytePos
Source§impl Ord for BytePos
impl Ord for BytePos
1.21.0 (const: unstable) · 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 PartialOrd for BytePos
impl PartialOrd for BytePos
impl StructuralPartialEq for BytePos
Auto Trait Implementations§
impl Freeze for BytePos
impl RefUnwindSafe for BytePos
impl Send for BytePos
impl Sync for BytePos
impl Unpin for BytePos
impl UnsafeUnpin for BytePos
impl UnwindSafe for BytePos
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