Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
ZeroConstant
and OneConstant
traits
Adds traits which are alternatives to the more dynamic `Zero`/`One` traits which are useful for stack-allocated types where it's possible to define constant values for zero/one. `ZeroConstant` bounds on `Zero` as a supertrait, and `OneConstant` on `One`, allowing them to be used as drop-in replacements. When a type also impls `PartialEq`, then `ZeroConstant` also provides a blanket impl of `Zero`, and likewise for `OneConstant`/`One`, making it simple for stack-allocated integers to impl these traits as an alternative to `Zero`/`One` while still remaining fully compatible. The internal impls of `Zero`/`One` on the numeric primitive types have been changed to use these traits, which should be a fully backwards-compatible change.
- Loading branch information