pub struct Position {
pub offset: usize,
pub line: usize,
pub column: usize,
}Expand description
Re-exported from deser, which counts positions the same way for errors. A position in the input.
Lines and columns are 1-based. Columns are counted in characters (bytes
that are not UTF-8 continuation bytes). This is how positions of errors
(see Error::line) are counted as well.
use deser::Position;
let pos = Position::of("[1,\n x]".as_bytes(), 6);
assert_eq!((pos.offset, pos.line, pos.column), (6, 2, 3));Fields§
§offset: usizeThe byte offset from the start of the input.
line: usizeThe line number (1-based).
column: usizeThe column number in characters (1-based).
Implementations§
Trait Implementations§
impl Copy for Position
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 Freeze 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