pub struct Range { /* private fields */ }Expand description
A two-position type, representing a span of characters.
Implementations§
source§impl Range
impl Range
sourcepub fn new(start: Position, end: Position) -> Range
pub fn new(start: Position, end: Position) -> Range
Creates a new buffer range. Checks and swaps arguments in the event that the end precedes the start.
pub fn start(&self) -> Position
pub fn end(&self) -> Position
sourcepub fn includes(&self, position: &Position) -> bool
pub fn includes(&self, position: &Position) -> bool
Whether or not the range includes the specified position. The range is exclusive, such that its ending position is not included.
Examples
use scribe::buffer::{Position, Range};
// Builder a range.
let range = Range::new(
Position{ line: 0, offset: 0 },
Position{ line: 1, offset: 5 }
);
assert!(range.includes(
&Position{ line: 1, offset: 0 }
));
assert!(range.includes(
&Position{ line: 1, offset: 4 }
));
assert!(!range.includes(
&Position{ line: 1, offset: 5 }
));Trait Implementations§
source§impl PartialEq for Range
impl PartialEq for Range
impl StructuralPartialEq for Range
Auto Trait Implementations§
impl RefUnwindSafe for Range
impl Send for Range
impl Sync for Range
impl Unpin for Range
impl UnwindSafe for Range
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more