pub struct Position {
pub line: u32,
pub byte_in_line: u32,
}Expand description
A source position: 0-indexed line plus a 0-indexed byte offset into that line.
byte_in_line always points at a UTF-8 boundary (callers are responsible).
Fields§
§line: u320-indexed line number.
byte_in_line: u320-indexed byte offset within line.
Implementations§
Source§impl Position
impl Position
Sourcepub fn to_byte_offset(self, rope: &Rope) -> Result<usize, Error>
pub fn to_byte_offset(self, rope: &Rope) -> Result<usize, Error>
Translate to the absolute source byte offset in rope.
§Errors
Returns Error::OutOfBounds when the line or byte fall outside the
rope’s content, or when byte_in_line is not a UTF-8 char boundary.
Sourcepub fn from_byte_offset(rope: &Rope, byte: usize) -> Result<Self, Error>
pub fn from_byte_offset(rope: &Rope, byte: usize) -> Result<Self, Error>
Construct a Position from an absolute byte offset in rope.
§Errors
Returns Error::OutOfBounds when byte exceeds the rope length or
does not land on a UTF-8 char boundary.
Trait Implementations§
impl Copy for Position
Source§impl<'de> Deserialize<'de> for Position
impl<'de> Deserialize<'de> for Position
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 Position
Source§impl Ord for Position
impl Ord for Position
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialOrd for Position
impl PartialOrd for Position
impl StructuralPartialEq for Position
Auto Trait Implementations§
impl Forget for Position
impl Freeze for Position
impl Move for Position
impl RefUnwindSafe for Position
impl Send for Position
impl Sync for Position
impl Unpin for Position
impl UnsafeUnpin for Position
impl UnwindSafe for Position
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