pub struct SourceIndex(/* private fields */);
Expand description
SourceIndex is a compact representation of a byte index in a specific source file.
It has a canonical representation for “unknown” indices, similar to that of [SourceSpan]
Implementations§
Source§impl SourceIndex
impl SourceIndex
Sourcepub const UNKNOWN: Self
pub const UNKNOWN: Self
Represents an invalid/unknown SourceIndex
Sourcepub fn new(source: SourceId, index: ByteIndex) -> Self
pub fn new(source: SourceId, index: ByteIndex) -> Self
Constructs a new SourceIndex from a SourceId and a ByteIndex
Sourcepub fn source_id(&self) -> SourceId
pub fn source_id(&self) -> SourceId
Returns the SourceId corresponding to this SourceIndex
Sourcepub fn index(&self) -> ByteIndex
pub fn index(&self) -> ByteIndex
Returns the ByteIndex corresponding to this SourceIndex
Trait Implementations§
Source§impl Add<ByteOffset> for SourceIndex
impl Add<ByteOffset> for SourceIndex
Source§type Output = SourceIndex
type Output = SourceIndex
The resulting type after applying the
+
operator.Source§fn add(self, rhs: ByteOffset) -> Self
fn add(self, rhs: ByteOffset) -> Self
Performs the
+
operation. Read moreSource§impl Add<usize> for SourceIndex
impl Add<usize> for SourceIndex
Source§impl AddAssign<ByteOffset> for SourceIndex
impl AddAssign<ByteOffset> for SourceIndex
Source§fn add_assign(&mut self, rhs: ByteOffset)
fn add_assign(&mut self, rhs: ByteOffset)
Performs the
+=
operation. Read moreSource§impl AddAssign<usize> for SourceIndex
impl AddAssign<usize> for SourceIndex
Source§fn add_assign(&mut self, rhs: usize)
fn add_assign(&mut self, rhs: usize)
Performs the
+=
operation. Read moreSource§impl Clone for SourceIndex
impl Clone for SourceIndex
Source§fn clone(&self) -> SourceIndex
fn clone(&self) -> SourceIndex
Returns a duplicate of the value. Read more
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for SourceIndex
impl Debug for SourceIndex
Source§impl Default for SourceIndex
impl Default for SourceIndex
Source§impl Hash for SourceIndex
impl Hash for SourceIndex
Source§impl Ord for SourceIndex
impl Ord for SourceIndex
Source§fn cmp(&self, other: &SourceIndex) -> Ordering
fn cmp(&self, other: &SourceIndex) -> 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 SourceIndex
impl PartialEq for SourceIndex
Source§impl PartialOrd for SourceIndex
impl PartialOrd for SourceIndex
Source§impl Sub<usize> for SourceIndex
impl Sub<usize> for SourceIndex
Source§impl SubAssign<usize> for SourceIndex
impl SubAssign<usize> for SourceIndex
Source§fn sub_assign(&mut self, rhs: usize)
fn sub_assign(&mut self, rhs: usize)
Performs the
-=
operation. Read moreimpl Copy for SourceIndex
impl Eq for SourceIndex
impl StructuralPartialEq for SourceIndex
Auto Trait Implementations§
impl Freeze for SourceIndex
impl RefUnwindSafe for SourceIndex
impl Send for SourceIndex
impl Sync for SourceIndex
impl Unpin for SourceIndex
impl UnwindSafe for SourceIndex
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