MCPcopy Create free account
hub / github.com/douglance/devsql / line_for_byte

Method line_for_byte

crates/devsql/src/providers/mod.rs:51–56  ·  view source on GitHub ↗

Convert a byte offset into a 1-based line number.

(&self, byte: usize)

Source from the content-addressed store, hash-verified

49
50 /// Convert a byte offset into a 1-based line number.
51 pub fn line_for_byte(&self, byte: usize) -> usize {
52 match self.line_starts.binary_search(&byte) {
53 Ok(idx) => idx + 1,
54 Err(idx) => idx,
55 }
56 }
57
58 /// Convert a byte offset into a 1-based column number.
59 pub fn column_for_byte(&self, byte: usize) -> usize {

Callers 3

Calls

no outgoing calls

Tested by

no test coverage detected