The tutorial (17.7) says the following: "We can write a trait declaration that inherits from other traits, called supertraits. Types that implement a trait must also implement its supertraits.
Since num::Zero inherits from Add<Self, Self>, you must implement it (the supertrait) also. On 2014-06-04, at 11:25, Rémi Fontan <[email protected]> wrote: > Hi, > > when compiling following code I get following error: > use std::num; > struct vec2d { a:f32, b:f32 } > impl num::Zero for vec2d { > fn zero() -> vec2d { > vec2d{a:0.0, b:0.0} > } > > fn is_zero(&self) -> bool { > self.a==0.0 && self.b==0.0 > } > } > > > > test.rs:4:1: 12:2 error: failed to find an implementation of trait > std::ops::Add<vec2d,vec2d> for vec2d > test.rs:4 impl num::Zero for vec2d { > test.rs:5 fn zero() -> vec2d { > test.rs:6 vec2d{a:0.0, b:0.0} > test.rs:7 } > test.rs:8 > test.rs:9 fn is_zero(&self) -> bool { > > > Would you know why the Add trait seems to be a requirement for implementing > the zero trait. > > cheers, > > Rémi > > > _______________________________________________ > 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
