pub struct Site {
pub si: usize,
pub pos: usize,
pub ri: usize,
pub ci: usize,
}Expand description
One location in the source text: the index reached, and the row and
column that index sits at. It is the same data TypeScript carries as
the loose sI/rI/cI fields on both Point and Token
(ts/src/lexer.ts), and as the ScanOut record its scan driver writes
back — naming it once is what keeps those uses in step.
The extra field is pos, and it is not extra data: TypeScript indexes
source by UTF-16 code unit and reports that same number in a
diagnostic, while Rust slices by UTF-8 byte. So si is the offset
this port slices with and pos is the offset it REPORTS, and the two
together say what TypeScript’s single sI says. See
go/doc/differences.md and DIVERGENCE.md “Column positions for astral
characters” for what that costs at the edges.
Deliberately NOT carrying a length: Point::len is the length of the
whole source and Token::len is the length of that token’s matched
text, so the two mean different things and only the position is shared.
Fields§
§si: usize§pos: usize§ri: usize§ci: usizeTrait Implementations§
impl Copy for Site
impl Eq for Site
impl StructuralPartialEq for Site
Auto Trait Implementations§
impl Freeze for Site
impl RefUnwindSafe for Site
impl Send for Site
impl Sync for Site
impl Unpin for Site
impl UnsafeUnpin for Site
impl UnwindSafe for Site
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.