|
|
|
|
|
by fweimer
949 days ago
|
|
The Box type, as used in the return type, transfers ownership to the calling function, so a check in the deallocator path would be needed to recognize this special object and avoid deallocating it. GCC has an emergency pool for its exception allocations, which is also quite ugly. And of course that pool can be too small. It should be possible to add a third arm to that Result type, returning some &'static reference, but I'm not sure how to do it in a backwards-compatibile way. |
|
static ALLOCATION_ERROR: Box<dyn Error> = (something);
and then use this variable whenever there is an allocation error. you might need unsafe { } but that's okay, the stdlib is full of unsafe