3 ms·
I mean, allocate something like static ALLOCATION_ERROR: Box<dyn Error> = (something); and then use this variable whenever there is an allocation error. you m
by nextaccountic 3y ago
I mean, allocate something like
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
- fweimer 3y agoIf you use it for producing the Box in the return value, you have to move out of it, and then it's gone. If you don't move it, you have a use-after-free bug after the first such panic has been caught and the box has been dropped as a result.