4 ms·
Obviously you should use whatever language you want on your projects, but in case you’re interested: > unfortunately, asking rust to treat UTF-8 string as a "b
by anderskaseorg 7y ago
Obviously you should use whatever language you want on your projects, but in case you’re interested:
> unfortunately, asking rust to treat UTF-8 string as a "ball of bytes" is hard, when it's stupidly easy with C.
String::as_bytes seems pretty easy, and there are byte literals b'?' of type u8 and b"???" of type [u8]. You can avoid interacting with the UTF-8 types at all if you don’t want to.
> Plus, I wanted to use arena-style-allocation where I make huge allocations in one go and then don't think about memory, something that I don't have control over in Rust.
Perhaps the bumpalo and typed-arena crates would interest you.
https://docs.rs/bumpalo/ https://docs.rs/bumpalo/
https://docs.rs/typed-arena/ https://docs.rs/typed-arena/
- kevincox 7y agoUnfortunately `&[u8]` is missing a lot of convenience methods that are on `&str`. It is getting better over time but I have definitely encounter the problem before where I tried to switch some string-based code to byte-based and was disappointed by the missing functionality.
- llogiq 7y agoThen perhaps the bstr crate (https://docs.rs/bstr/0.2.12/bstr https://docs.rs/bstr/0.2.12/bstr) might be what you want.