Closed TheDan64 closed 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:
Would you expect these methods to return an Err
if the current chunk that we're bumping out of is full or only if the global allocator returns an error for getting a new chunk to bump out of?
A variant for each? I.e. try_alloc_in_current_chunk
and try_alloc_in_new_chunk_if_necessary
?
Finally, are you interested in doing the implementation work?
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.
Ok, let's start with just the conservative approach of only when the global allocator fails :+1:
I tried to add these try_* methods (since I need fallible allocation) to
Vec
by wrapping theRawVec
methods of the same names. However, they still seem to be infallible due to the alloc impl always returningOk
? https://github.com/fitzgen/bumpalo/blob/master/src/lib.rs#L1076Would it be possible to make them fallible?