[][src]Struct codespan::ByteOffset

pub struct ByteOffset(pub RawOffset);

A byte offset in a source file

Methods

impl ByteOffset[src]

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

Create a byte offset from a UTF8-encoded character

use codespan::ByteOffset;

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

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

Create a byte offset from a UTF- encoded string

use codespan::ByteOffset;

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

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

Convert the offset into a usize, for use in array indexing

Trait Implementations

impl Offset for ByteOffset[src]

impl Clone for ByteOffset[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl PartialEq<ByteOffset> for ByteOffset[src]

impl PartialOrd<ByteOffset> for ByteOffset[src]

impl Eq for ByteOffset[src]

impl Ord for ByteOffset[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

impl Copy for ByteOffset[src]

impl From<i64> for ByteOffset[src]

impl Default for ByteOffset[src]

impl Hash for ByteOffset[src]

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0
[src]

Feeds a slice of this type into the given [Hasher]. Read more

impl Display for ByteOffset[src]

impl Debug for ByteOffset[src]

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 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 Neg 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 SubAssign<ByteOffset> for ByteOffset[src]

impl SubAssign<ByteOffset> for ByteIndex[src]

Auto Trait Implementations

impl Send for ByteOffset

impl Sync for ByteOffset

Blanket Implementations

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

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

impl<T> From for T[src]

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

type Owned = T

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

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

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

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

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

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

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.