hydroper_source_text

Crates.iohydroper_source_text
lib.rshydroper_source_text
version1.0.3
sourcesrc
created_at2024-04-08 19:40:37.007368
updated_at2024-04-09 10:58:44.736515
descriptionSource text containing line locations.
homepage
repositoryhttps://github.com/hydroper/rust-source-text
max_upload_size
id1201031
size14,460
Matheus Dias de Souza (hydroper)

documentation

README

Source text

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.

Example

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));
Commit count: 9

cargo fmt