Struct scribe::buffer::Position [] [src]

pub struct Position {
    pub line: usize,
    pub offset: usize,
}

A two (zero-based) coordinate value representing a location in a buffer. The offset field is so named to emphasize that positions point to locations before/after characters, not characters themselves, in an effort to avoid fencepost errors.

Fields

Methods

impl Position
[src]

Creates a new position with a line/offset of 0.

Examples

use scribe::buffer::Position;

let mut position = Position::new();
assert_eq!(position, Position{
    line: 0,
    offset: 0
});

Adds the specified Distance to the position.

Examples

use scribe::buffer::{Distance, Position};

let mut position = Position{ line: 1, offset: 3 };
let distance = Distance{ lines: 1, offset: 4 };
position.add(&distance);

assert_eq!(position, Position{
    line: 2,
    offset: 4
});

Trait Implementations

impl Copy for Position
[src]

impl Clone for Position
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Debug for Position
[src]

Formats the value using the given formatter.

impl PartialEq for Position
[src]

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

This method tests for !=.

impl PartialOrd for Position
[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