Struct codespan::ByteOffset [] [src]

pub struct ByteOffset(pub RawOffset);

A byte offset in a source file

Methods

impl ByteOffset
[src]

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

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

[src]

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

Trait Implementations

impl Clone for ByteOffset
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl Copy for ByteOffset
[src]

impl PartialEq for ByteOffset
[src]

[src]

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

[src]

This method tests for !=.

impl Eq for ByteOffset
[src]

impl Hash for ByteOffset
[src]

[src]

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

1.3.0
[src]

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

impl PartialOrd for ByteOffset
[src]

[src]

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

[src]

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

[src]

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

[src]

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

[src]

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]

[src]

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

1.21.0
[src]

Compares and returns the maximum of two values. Read more

1.21.0
[src]

Compares and returns the minimum of two values. Read more

impl Default for ByteOffset
[src]

[src]

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

impl Debug for ByteOffset
[src]

[src]

Formats the value using the given formatter. Read more

impl Display for ByteOffset
[src]

[src]

Formats the value using the given formatter. Read more

impl From<RawOffset> for ByteOffset
[src]

[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.

[src]

Performs the + operation.

impl AddAssign<ByteOffset> for ByteIndex
[src]

[src]

Performs the += operation.

impl Neg for ByteOffset
[src]

The resulting type after applying the - operator.

[src]

Performs the unary - operation.

impl Add<ByteOffset> for ByteOffset
[src]

The resulting type after applying the + operator.

[src]

Performs the + operation.

impl AddAssign<ByteOffset> for ByteOffset
[src]

[src]

Performs the += operation.

impl Sub<ByteOffset> for ByteOffset
[src]

The resulting type after applying the - operator.

[src]

Performs the - operation.

impl SubAssign<ByteOffset> for ByteOffset
[src]

[src]

Performs the -= operation.

impl Sub<ByteOffset> for ByteIndex
[src]

The resulting type after applying the - operator.

[src]

Performs the - operation.

impl SubAssign<ByteOffset> for ByteIndex
[src]

[src]

Performs the -= operation.

Auto Trait Implementations

impl Send for ByteOffset

impl Sync for ByteOffset