num-bigint icon indicating copy to clipboard operation
num-bigint copied to clipboard

Out of memory management

Open ghost opened this issue 2 years ago • 1 comments

With try_reserve available for Vec, the checked operations (e.g. checked_add) could return None when out of memory.

Is this extension possible in checked traits?

ghost avatar Jun 12 '22 14:06 ghost

(Assuming we bump the MSRV to 1.57 for try_reserve...)

That's certainly possible, but I don't think it's a good idea, because the current purpose of those methods is only to detect arithmetic overflow. I think it would be semantically confusing for this to also conflate OOM.

Maybe it would make sense to have try_op methods which return a Result, and the error type could indicate the type of failure. It may be difficult to thread this through the more complicated operations though, like multiplication and division.

cuviper avatar Jun 15 '22 18:06 cuviper