[rust-dev] impl num::Zero and std::ops::Add error

Eric Reed ecreed at cs.washington.edu
Wed Apr 9 11:37:33 PDT 2014


If you implement Add on a type, then you should implement Zero to specify
the identity of the + operation on that type.

If you simply want to specify a default value, then you should implement
Default.
On Apr 9, 2014 11:25 AM, "Tommi Tissari" <rusty.gates at icloud.com> wrote:

> > On 09 Apr 2014, at 20:46, Kevin Ballard <kevin at sb.org> wrote:
> >
> > For reference, the Zero trait lives in std::num, which should be a good
> indication that this is a property of numeric types.
>
> Am I not supposed to use std::num::Zero for defining things like zero
> vector or zero matrix? Those are neither numbers nor zeroes.
>
> _______________________________________________
> Rust-dev mailing list
> Rust-dev at mozilla.org
> https://mail.mozilla.org/listinfo/rust-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/rust-dev/attachments/20140409/5f782e21/attachment.html>


More information about the Rust-dev mailing list