3 ms·
There’s already a `Wrapping<T>` struct in std for you. I don’t think you need to roll your own. Of course, it might make sense in the embedded space to do so.
by chewbacha 9y ago
There’s already a `Wrapping<T>` struct in std for you. I don’t think you need to roll your own.
Of course, it might make sense in the embedded space to do so.
- deleted 9y ago[deleted]
- jsheard 9y agoWrapping<T> actually comes from core and is just re-exported by std, so embedded targets that lack std support can still use it by importing directly from core. https://doc.rust-lang.org/core/num/struct.Wrapping.html https://doc.rust-lang.org/core/num/struct.Wrapping.html
- chewbacha 9y agoFantastic!
- Sharlin 9y ago`Wrapping<T>` is a great solution. When in doubt, encode the behavior in the type system.