Struct codespan::ByteOffset[][src]

pub struct ByteOffset(pub RawOffset);

A byte offset in a source file

Implementations

impl ByteOffset[src]

pub fn from_char_len(ch: char) -> ByteOffset[src]

Create a byte offset from a UTF8-encoded character

use codespan::ByteOffset;

assert_eq!(ByteOffset::from_char_len('A').to_usize(), 1);
assert_eq!(ByteOffset::from_char_len('ß').to_usize(), 2);
assert_eq!(ByteOffset::from_char_len('ℝ').to_usize(), 3);
assert_eq!(ByteOffset::from_char_len('💣').to_usize(), 4);

pub fn from_str_len(value: &str) -> ByteOffset[src]

Create a byte offset from a UTF- encoded string

use codespan::ByteOffset;

assert_eq!(ByteOffset::from_str_len("A").to_usize(), 1);
assert_eq!(ByteOffset::from_str_len("ß").to_usize(), 2);
assert_eq!(ByteOffset::from_str_len("ℝ").to_usize(), 3);
assert_eq!(ByteOffset::from_str_len("💣").to_usize(), 4);

pub const fn to_usize(self) -> usize[src]

Convert the offset 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 Add<ByteOffset> for ByteOffset[src]

type Output = ByteOffset

The resulting type after applying the + operator.

impl AddAssign<ByteOffset> for ByteIndex[src]

impl AddAssign<ByteOffset> for ByteOffset[src]

impl Clone for ByteOffset[src]

impl Copy for ByteOffset[src]

impl Debug for ByteOffset[src]

impl Default for ByteOffset[src]

impl Display for ByteOffset[src]

impl Eq for ByteOffset[src]

impl From<ByteOffset> for RawOffset[src]

impl From<i64> for ByteOffset[src]

impl Hash for ByteOffset[src]

impl Neg for ByteOffset[src]

type Output = ByteOffset

The resulting type after applying the - operator.

impl Offset for ByteOffset[src]

impl Ord for ByteOffset[src]

impl PartialEq<ByteOffset> for ByteOffset[src]

impl PartialOrd<ByteOffset> for ByteOffset[src]

impl StructuralEq for ByteOffset[src]

impl StructuralPartialEq for ByteOffset[src]

impl Sub<ByteOffset> for ByteOffset[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 ByteOffset[src]

impl SubAssign<ByteOffset> for ByteIndex[src]

Auto Trait Implementations

Blanket Implementations

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

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

impl<T> BorrowMut<T> for T where
    T: ?Sized
[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.