[][src]Struct gluon_base::pos::BytePos

pub struct BytePos(pub u32);

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 │

Implementations

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 Add<ByteOffset> for ByteIndex[src]

type Output = ByteIndex

The resulting type after applying the + operator.

impl AddAssign<ByteOffset> for ByteIndex[src]

impl<'ast, Id> AstClone<'ast, Id> for BytePos[src]

impl Clone for ByteIndex[src]

impl Copy for ByteIndex[src]

impl Debug for ByteIndex[src]

impl Default for ByteIndex[src]

impl Display for ByteIndex[src]

impl Eq for ByteIndex[src]

impl From<u32> for ByteIndex[src]

impl Hash for ByteIndex[src]

impl Index for ByteIndex[src]

impl Ord for ByteIndex[src]

impl PartialEq<ByteIndex> for ByteIndex[src]

impl PartialOrd<ByteIndex> for ByteIndex[src]

impl StructuralEq for ByteIndex[src]

impl StructuralPartialEq for ByteIndex[src]

impl Sub<ByteIndex> for ByteIndex[src]

type Output = ByteOffset

The resulting type after applying the - operator.

impl Sub<ByteOffset> for ByteIndex[src]

type Output = ByteIndex

The resulting type after applying the - operator.

impl SubAssign<ByteOffset> for ByteIndex[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Any for T where
    T: Any
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> CloneAny for T where
    T: Clone + Any
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.