num-bigint
num-bigint copied to clipboard
Out of memory management
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?
(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.