pub struct Offset(pub u64);Expand description
Represents a byte position/offset in a file or buffer.
This type wraps a u64 to provide type safety and prevent accidental mixing
of offsets with other numeric values. It supports:
- Addition and subtraction with
Size - Comparison with other offsets
- Conversion from
u64
§Examples
use codeq::{Offset, Size};
let offset = Offset(1000);
// Add or subtract sizes
let advanced = offset + Size(50);
assert_eq!(advanced, Offset(1050));
// Calculate distance between offsets
let size: Size = Offset(100) - Offset(50);
assert_eq!(size, Size(50));
// Offsets can be compared
assert!(Offset(100) > Offset(50));Tuple Fields§
§0: u64Trait Implementations§
Source§impl AddAssign<Size> for Offset
impl AddAssign<Size> for Offset
Source§fn add_assign(&mut self, rhs: Size)
fn add_assign(&mut self, rhs: Size)
Performs the
+= operation. Read moreSource§impl Ord for Offset
impl Ord for Offset
Source§impl PartialOrd for Offset
impl PartialOrd for Offset
Source§impl SubAssign<Size> for Offset
impl SubAssign<Size> for Offset
Source§fn sub_assign(&mut self, rhs: Size)
fn sub_assign(&mut self, rhs: Size)
Performs the
-= operation. Read moreimpl Copy for Offset
impl Eq for Offset
impl StructuralPartialEq for Offset
Auto Trait Implementations§
impl Freeze for Offset
impl RefUnwindSafe for Offset
impl Send for Offset
impl Sync for Offset
impl Unpin for Offset
impl UnwindSafe for Offset
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