fitzgen / bumpalo

A fast bump allocation arena for Rust
https://docs.rs/bumpalo
Apache License 2.0
1.42k stars 112 forks source link

Allocate OsStrs and Paths in a Bump? #81

Open sunshowers opened 4 years ago

sunshowers commented 4 years ago

It would be very convenient to support allocating OsStr and Path instances in a Bump.

Unfortunately the underlying byte representation isn't exposed on Windows, so we'll probably have to return Cow<'bump, OsStr> or Cow<'bump, Path> which may defeat the purpose :(

fitzgen commented 4 years ago

In addition to the Windows issues you mentioned, this crate is always no_std, and therefore doesn't have access to either OsStr or Path at all.

It is probably best to implement this functionality in a small helper function outside of this crate. It should be relatively easy to write such a helper on top of Bump::alloc_slice_copy.

sunshowers commented 4 years ago

Thanks. Feel free to close this issue then. Would it be worth documenting this somewhere?

fitzgen commented 4 years ago

Would it be worth documenting this somewhere?

this = "always no_std" or something else?

If you end up writing a crate that adds this helper, I'm happy to link to it from the README as well!

sunshowers commented 4 years ago

this = "always no_std" or something else?

ahh, good question! both of those things I guess? that bumpalo is always no_std and that this + the Windows issues are why alloc_os_str etc aren't present.