Zero is a bad name here, it should be renamed or removed 2014年4月9日 上午1:20于 "Kevin Ballard" <[email protected]>写道:
> On Apr 7, 2014, at 1:02 AM, Tommi Tissari <[email protected]> wrote: > > On 07 Apr 2014, at 08:44, Nicholas Radford <[email protected]> > wrote: > > I think the original question was, why does the zero trait require the add > trait. > > If that was the original question, then my answer would be that > std::num::Zero requires the Add trait because of the way it is specified: > "Defines an additive identity element for Self". Then the question > becomes: "why is Zero specified like that?", and I would answer: because > then you can use it in generic algorithms which require their argument(s) > to have an additional identity. > > > If you want a zero value for a type that doesn't support addition, > std::default::Default may be a good choice to use. Semantically, that > actually returns the "default value" for a type instead of the "zero > value", but in a type without addition, how do you define "zero value"? > > -Kevin > > _______________________________________________ > Rust-dev mailing list > [email protected] > https://mail.mozilla.org/listinfo/rust-dev > >
_______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
