#string-processing #file-line #line-column #information #spans

spanned

string processing with file/line/col information and the regular rust str API

10 releases

0.3.0 Jul 24, 2024
0.2.1 May 21, 2024
0.1.6 Feb 27, 2024
0.1.5 Nov 13, 2023
0.1.3 Oct 22, 2023

#8 in #line-column

Download history 5442/week @ 2024-07-30 7585/week @ 2024-08-06 5300/week @ 2024-08-13 4457/week @ 2024-08-20 4149/week @ 2024-08-27 5116/week @ 2024-09-03 5399/week @ 2024-09-10 4600/week @ 2024-09-17 4317/week @ 2024-09-24 4144/week @ 2024-10-01 4747/week @ 2024-10-08 4177/week @ 2024-10-15 4486/week @ 2024-10-22 4756/week @ 2024-10-29 4157/week @ 2024-11-05 4038/week @ 2024-11-12

18,040 downloads per month
Used in 3 crates (via ui_test)

MIT/Apache

10KB
240 lines

Simple span handling for str and &[u8]

This crate exposes some of the methods that exist on str or bstr. If you are missing any you need, please open issues or PRs.

The basic usage is to read from a file and then use the methods to modify it:

let file = Spanned<String>::read_from_file(path)?;
for line in file.lines() {
    if let Some(rest) = line.strip_prefix("cake:") {
        println!("found a cake at {}: {}", rest.span.line_start, *rest);
    }
}

any Spanned object will always know its file, line and column information and correctly preserve it across operations that take subslices. The column information is counted in the number of utf8 characters, which is not entirely correct. Please open an issue if you encounter this to be a problem.

Dependencies

~3.5–9MB
~79K SLoC