BurntSushi / fst

Represent large sets and maps compactly with finite state transducers.
The Unlicense
1.76k stars 123 forks source link

Create Str and Subsequence automata from bytes #169

Open jfolz opened 1 month ago

jfolz commented 1 month ago

I was wondering if there is any particular reason why Str and Subsequence automata can only be created from strings. The other parts of the API that I've looked at so far all take arbitrary byte sequences. I'm still quite new to Rust, but changing Str::new and Subsequence::new to take an AsRef<[u8]> seems to work fine.

BurntSushi commented 1 month ago

I think it's just an oversight. I'd be willing to accept a PR that adds impl From<&'a [u8]> for {Str,Subsequence}. I realize that we could just modify new to accept an AsRef<[u8]>, but this is susceptible to inference failures.