pub struct Loc {
pub line: isize,
pub col: isize,
pub pos: isize,
pub source: Rc<Source>,
}
Expand description
Loc(line, col, pos, source)
is a location referring to line line
and
column col
of source
, where the combination of line
and col
produces
a direct offset pos
. It is formatted as "{source}:{line}:{col}"
where
{source}
is the formatted substitution of source
and likewise for
line
/col
. It is required that no numeric field is negative, that is,
line
, col
, and pos
should be treated as if they were of type usize
.
Fields§
§line: isize
§col: isize
§pos: isize
§source: Rc<Source>
Implementations§
Source§impl Loc
impl Loc
Sourcepub fn lines(&self, before: usize, after: usize) -> (Vec<String>, usize)
pub fn lines(&self, before: usize, after: usize) -> (Vec<String>, usize)
loc.lines(before, after)
is a pair of a vector containing the
line in loc.source
at position loc.pos
, preceded by the up to
before
previous lines and up to after
subsequent lines, as well
as an index into the vector for the line containing loc.pos
.
Requires: loc.pos
is a valid position in loc.source
.
pub fn make_invalid() -> Self
pub fn is_invalid(&self) -> bool
Trait Implementations§
Source§impl PartialOrd for Loc
impl PartialOrd for Loc
impl Eq for Loc
Auto Trait Implementations§
impl Freeze for Loc
impl RefUnwindSafe for Loc
impl !Send for Loc
impl !Sync for Loc
impl Unpin for Loc
impl UnwindSafe for Loc
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