pub struct Range {
pub start: Position,
pub end: Position,
}Expand description
A half-open [start, end) range expressed as two Positions.
The vim-grammar Range (line ranges, marks, patterns, :%, Selection,
custom) lives in lattice-grammar; this is the protocol-level structural
range used by edits and decorations.
start is included, end is not, so start == end is a zero-width range
(an insertion point). The constructors do not order or validate the
endpoints; a well-formed range has start <= end, and consumers reject an
inverted one (ProtocolError::InvalidRange).
§Examples
use lattice_protocol::{Position, Range};
// The first three bytes of line 0 — "abc" in "abcdef".
let abc = Range::new(Position::new(0, 0), Position::new(0, 3));
assert!(!abc.is_empty());
// A range may span lines; `end` is exclusive.
let two_lines = Range::new(Position::new(1, 4), Position::new(2, 0));
assert_eq!(two_lines.end.line, 2);
// An insertion point.
assert!(Range::empty(Position::new(3, 1)).is_empty());Fields§
§start: PositionFirst position inside the range (inclusive).
end: PositionFirst position past the range (exclusive).
Implementations§
Trait Implementations§
impl Copy for Range
Source§impl<'de> Deserialize<'de> for Range
impl<'de> Deserialize<'de> for Range
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Range
impl StructuralPartialEq for Range
Auto Trait Implementations§
impl Freeze for Range
impl RefUnwindSafe for Range
impl Send for Range
impl Sync for Range
impl Unpin for Range
impl UnsafeUnpin 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.