nutype icon indicating copy to clipboard operation
nutype copied to clipboard

Add checked operations for integer based newtypes

Open Kamil729 opened this issue 10 months ago β€’ 1 comments

This PR implements checked arithmetic operations for newtypes whose inner types are integers. It adds an attribute, similar to new_unchecked that enable this.

I considered implementing this as a num_traits derives, but those require regular operators to be implemented for those types, so I wanted some feedback on this.

I was also thinking about implementing wrapping and saturating variants, but again I would like to get some feedback on this beforehand.

Kamil729 avatar Mar 06 '25 10:03 Kamil729

Hi, thanks for the PR, but I don't think i will be willing to merge it. My vision on achieving a similar goal would be rather something like a map function that returns Result.

greyblake avatar Mar 19 '25 09:03 greyblake

Thanks again for the effort and thought you put into this. πŸ™

After giving it some more thought, I’ve decided to close this PR as I’d prefer to take a different direction with the project.

greyblake avatar Jul 26 '25 10:07 greyblake