| Crates.io | realhydroper-sourcetext |
| lib.rs | realhydroper-sourcetext |
| version | 1.0.1 |
| created_at | 2025-02-19 13:06:41.525908+00 |
| updated_at | 2025-02-25 12:25:10.967906+00 |
| description | Source text containing line locations. |
| homepage | |
| repository | https://github.com/realhydroper/rustsourcetext |
| max_upload_size | |
| id | 1561302 |
| size | 26,493 |
Library for storing efficient line offset and column from std::string::String. It processes lines only once at the first invokation of any of the retrieval methods.
Here is a basic example:
// offset 5 = "bar"
let text = SourceText::new("foo\r\nbar\r\nqux".into());
assert_eq!(0, text.get_column(5));
assert_eq!(2, text.get_line_number(5));
assert_eq!(5, text.get_line_offset(2).unwrap());
assert_eq!(5, text.get_line_offset_from_offset(7));