Commit 06c0ee0
Add
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.ZeroConstant and OneConstant traits1 parent 29c5b46 commit 06c0ee0
1 file changed
+48
-18
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
31 | 53 | | |
32 | 54 | | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
| 55 | + | |
| 56 | + | |
42 | 57 | | |
43 | 58 | | |
44 | 59 | | |
| |||
115 | 130 | | |
116 | 131 | | |
117 | 132 | | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
118 | 155 | | |
119 | 156 | | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
| 157 | + | |
| 158 | + | |
129 | 159 | | |
130 | 160 | | |
131 | 161 | | |
| |||
0 commit comments