pub struct At {
pub line: usize,
pub column: usize,
}Expand description
Where in the source something is, counted from one as an editor counts.
Fields§
§line: usizeLine, from 1.
column: usizeColumn, from 1.
Implementations§
Source§impl At
impl At
Sourcepub fn of(source: &str, offset: usize) -> Self
pub fn of(source: &str, offset: usize) -> Self
The position of a byte offset in source.
Computed on demand rather than carried around: the parser hands back byte spans, and a form that loads without complaint should not have paid for counting newlines.
let source = "form \"F\" version=1\n label \"æøå\" x=0\n";
assert_eq!(At::of(source, 0), At { line: 1, column: 1 });
// Characters, not bytes, so a column points where a caret would be even
// on a line with an `æ` in it.
assert_eq!(At::of(source, source.len() - 1).line, 2);Trait Implementations§
impl Copy for At
impl Eq for At
impl StructuralPartialEq for At
Auto Trait Implementations§
impl Freeze for At
impl RefUnwindSafe for At
impl Send for At
impl Sync for At
impl Unpin for At
impl UnsafeUnpin for At
impl UnwindSafe for At
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