Robbepop / apint

Arbitrary precision integers library.
Other
27 stars 4 forks source link

Make `BitWidth` use `NonZeroUsize` #39

Open AaronKutch opened 5 years ago

AaronKutch commented 5 years ago

The compiler has special optimizations for this. In fact, I might just replace BitWidth altogether, but I will have to try that in an experimental branch in the future.

Robbepop commented 5 years ago

I was also already thinking about this and also to use other things such as MaybeUninit, ManuallyDrop. I think apint could make use a lot more of those new abstractions.

AaronKutch commented 5 years ago

Yeah. I learned a bunch about manipulating pointers and using MaybeUninit when working on my ptr_rotate PR, so I will do this.

AaronKutch commented 5 years ago

I was considering replacing BitWidth altogether with NonZeroUsize, but I have decided to keep it as a wrapper type around a NonZeroUsize. I found it unlikely that we would use unused bits in the len, but someone might want to clone the library and use NonZeroU32 or something else special.