Skip to main content

Offset

Type Alias Offset 

Source
pub type Offset = usize;
Expand description

A boundary in a source buffer, as a byte offset.

Boundaries sit between bytes rather than on them, so a span’s end is the offset past its last byte and end - start is its length. One offset is enough because a span’s only job is to index a buffer: line and column are facts about a particular buffer’s contents, recovered from it when something needs to display a location, and so they belong with the buffer rather than with the span. This is what rustc does too — its Span stores lo and hi byte positions and nothing else, and SourceMap binary-searches a line table on demand.