Struct codespan::ByteOffset[][src]

pub struct ByteOffset(pub RawOffset);

A byte offset in a source file

Methods

impl 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);

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);

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

Trait Implementations

impl Clone for ByteOffset
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Copy for ByteOffset
[src]

impl PartialEq for ByteOffset
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl Eq for ByteOffset
[src]

impl Hash for ByteOffset
[src]

Feeds this value into the given [Hasher]. Read more

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

impl PartialOrd for ByteOffset
[src]

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl Ord for ByteOffset
[src]

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

impl Default for ByteOffset
[src]

Returns the "default value" for a type. Read more

impl Debug for ByteOffset
[src]

Formats the value using the given formatter. Read more

impl Display for ByteOffset
[src]

Formats the value using the given formatter. Read more

impl From<RawOffset> for ByteOffset
[src]

Performs the conversion.

impl Offset for ByteOffset
[src]

ZERO: ByteOffset = ByteOffset(0)

impl Add<ByteOffset> for ByteIndex
[src]

The resulting type after applying the + operator.

Performs the + operation.

impl AddAssign<ByteOffset> for ByteIndex
[src]

Performs the += operation.

impl Neg for ByteOffset
[src]

The resulting type after applying the - operator.

Performs the unary - operation.

impl Add<ByteOffset> for ByteOffset
[src]

The resulting type after applying the + operator.

Performs the + operation.

impl AddAssign<ByteOffset> for ByteOffset
[src]

Performs the += operation.

impl Sub<ByteOffset> for ByteOffset
[src]

The resulting type after applying the - operator.

Performs the - operation.

impl SubAssign<ByteOffset> for ByteOffset
[src]

Performs the -= operation.

impl Sub<ByteOffset> for ByteIndex
[src]

The resulting type after applying the - operator.

Performs the - operation.

impl SubAssign<ByteOffset> for ByteIndex
[src]

Performs the -= operation.

Auto Trait Implementations

impl Send for ByteOffset

impl Sync for ByteOffset