[−][src]Struct gluon_base::pos::BytePos
A byte position in a source file. The index is continuous, running over all
files in a CodeMap
, starting with 1. Zero is reserved for positions that
do not point to a valid file. One byte of padding is added between each file.
For example, for these files:
main.rs
:pub struct
(10 bytes)lib.rs
:Span::new
(9 bytes)
ByteIndex(0)
points to no file at all, ByteIndex(2)
points at the
second byte (index 1) in main.rs
and ByteIndex(14)
points at the third
byte (index 2) in lib.rs
.
You can visualize the indices like this:
main.rs lib.rs
content │ █ │ p │ u │ b │ │ s │ t │ r │ u │ c │ t │ █ │ S │ p │ a │ n │ : │ : │ n │ e │ w │
───────────┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
file index │ █ │ 0 │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ █ │ 0 │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │
───────────┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
ByteIndex │ 0 │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │10 │11 │12 │13 │14 │15 │16 │17 │18 │19 │20 │
Methods
impl ByteIndex
[src]
pub fn none() -> ByteIndex
[src]
A byte position that will never point to a valid file
pub fn to_usize(self) -> usize
[src]
Convert the position into a usize
, for use in array indexing
Trait Implementations
impl Eq for ByteIndex
[src]
impl Index for ByteIndex
[src]
type Offset = ByteOffset
impl Default for ByteIndex
[src]
impl Copy for ByteIndex
[src]
impl Sub<ByteOffset> for ByteIndex
[src]
type Output = ByteIndex
The resulting type after applying the -
operator.
fn sub(self, rhs: ByteOffset) -> ByteIndex
[src]
impl Sub<ByteIndex> for ByteIndex
[src]
type Output = ByteOffset
The resulting type after applying the -
operator.
fn sub(self, rhs: ByteIndex) -> ByteOffset
[src]
impl SubAssign<ByteOffset> for ByteIndex
[src]
fn sub_assign(&mut self, rhs: ByteOffset)
[src]
impl Display for ByteIndex
[src]
impl AddAssign<ByteOffset> for ByteIndex
[src]
fn add_assign(&mut self, rhs: ByteOffset)
[src]
impl Ord for ByteIndex
[src]
fn cmp(&self, other: &ByteIndex) -> Ordering
[src]
fn max(self, other: Self) -> Self
1.21.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
Compares and returns the minimum of two values. Read more
fn clamp(self, min: Self, max: Self) -> Self
[src]
clamp
)Restrict a value to a certain interval. Read more
impl Clone for ByteIndex
[src]
fn clone(&self) -> ByteIndex
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl PartialEq<ByteIndex> for ByteIndex
[src]
impl Debug for ByteIndex
[src]
impl From<u32> for ByteIndex
[src]
impl Add<ByteOffset> for ByteIndex
[src]
type Output = ByteIndex
The resulting type after applying the +
operator.
fn add(self, rhs: ByteOffset) -> ByteIndex
[src]
impl Hash for ByteIndex
[src]
fn hash<__H>(&self, state: &mut __H) where
__H: Hasher,
[src]
__H: Hasher,
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl PartialOrd<ByteIndex> for ByteIndex
[src]
Auto Trait Implementations
impl Sync for ByteIndex
impl Unpin for ByteIndex
impl Send for ByteIndex
impl UnwindSafe for ByteIndex
impl RefUnwindSafe for ByteIndex
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,