Crates.io | spanned |
lib.rs | spanned |
version | 0.3.0 |
source | src |
created_at | 2023-10-21 15:47:33.430072 |
updated_at | 2024-07-24 14:38:41.813076 |
description | string processing with file/line/col information and the regular rust `str` API |
homepage | |
repository | |
max_upload_size | |
id | 1010090 |
size | 10,077 |
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.