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
line: usize
offset: usize
Methods
impl Position
[src]
fn new() -> Position
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 });
fn add(&mut self, distance: &Distance)
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]
fn clone(&self) -> Position
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl Debug for Position
[src]
impl PartialEq for Position
[src]
fn eq(&self, __arg_0: &Position) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Position) -> bool
This method tests for !=
.
impl PartialOrd for Position
[src]
fn partial_cmp(&self, other: &Position) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool
1.0.0
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Rhs) -> bool
1.0.0
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Rhs) -> bool
1.0.0
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Rhs) -> bool
1.0.0
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more