[ANN] bstr 0.1.0 (byte strings for Rust)

#1

Repo: https://github.com/BurntSushi/bstr

Docs: https://docs.rs/bstr

For a long time now, I’ve been mulling over what a real byte string type in Rust would look like. They turn out to be fairly useful when dealing with files or data that you otherwise expect to be text/ASCII-compatible, but do not have any guarantee that it actually is. Rust’s Vec<u8>/&[u8] is somewhat serviceable for these things as a container, but there are lots of “string” oriented APIs missing from this type. For example, iterating over codepoints/graphemes/words/sentences, changing case, substring search, iterating over lines, splitting, etc. All of these things (and more) are provided by bstr.

The README and docs contain more details about motivation and future work. There are also tons of examples in the docs, and I tried to add higher level “guidance” where I could to try to nudge folks toward more correct APIs.

13 Likes
#2

Thanks for creating this crate @BurntSushi. :slight_smile:

One comment on name: BSTR is a well-known string type on Windows. So the name ‘bstr’ may cause some confusion especially to Windows people as to the intent of the crate.

#3

I think the potential for confusion is pretty limited. Thanks for the heads up, but I’m sticking with the name.