fitzgen / bumpalo

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

Add try_reserve/_exact methods for Vec? #66

Closed TheDan64 closed 4 years ago

TheDan64 commented 4 years ago

I tried to add these try_* methods (since I need fallible allocation) to Vec by wrapping the RawVec methods of the same names. However, they still seem to be infallible due to the alloc impl always returning Ok? https://github.com/fitzgen/bumpalo/blob/master/src/lib.rs#L1076

Would it be possible to make them fallible?

fitzgen commented 4 years ago

Thanks for opening an issue. I'm open to the idea, but I still have some design questions I'm unsure about:

Finally, are you interested in doing the implementation work?

TheDan64 commented 4 years ago

Yeah, I'd be interested in implementation.

Personally, I'm only concerned about when the global allocator fails. However, if you think there's value in adding the other variant then we could do that too. Or at the very least keep the code open to adding that variant when someone does require it.

fitzgen commented 4 years ago

Ok, let's start with just the conservative approach of only when the global allocator fails :+1: