I'm working on a parser. The parser takes an input in [u8]
and spits out offsets. E.g. imagine it works like following:
"String value"
// ^ ^
// | |
// 0 14
// The `^` denotes spans, so they would effectively be
Seeing how all my separators are always ASCII and the spans return will always return the position of said chars, do I need to make following trait unsafe
?
trait ParserSearcher {
fn find_quote(&[u8]) -> [usize];
}
// typical usage
let search = ParserSearcher::find_quote(bytes);
let quoted = unsafe {
bytes.get_unchecked(search[0], search[1])
}
In theory, it could be used to extract invalid points in a byte array?
I ask because it's similar but unsure if same as Rust Searcher trait.