logoalt Hacker News

dnauticsyesterday at 9:31 PM1 replyview on HN

I'm aware that a rust enum isn't just an integer? How would it have a payload if it were just an integer?

right. If allocerror only has size field, where do you stash the unwind information (which could be of arbitrary size)


Replies

dwatttttyesterday at 10:16 PM

There's a few confusing things here. For one, just because the allocator gave you an AllocError, that doesn't mean your function has to return an AllocError: you can return whatever error type you choose. If you want to collect a stack trace at that point, put one in there.

What value would a stack trace that includes internal allocator functions be to you? What do you lose by having to collect the stack trace at the point where your function receives an AllocError?