[rust-dev] conflicting implementations for trait

Arkadii Rost arkrost at gmail.com
Tue Jul 1 13:38:59 PDT 2014


Hi,

Can I override trait impl in another module?

For example, I want to do something like this

use foo_mod::MyTrait;

mod foo_mod {
pub trait MyTrait {
fn foo (&self) -> int;
}

impl MyTrait for int {
fn foo(&self) -> int {
return self + 2;
}
}

impl MyTrait for ~str {
fn foo(&self) -> int {
return 42;
}
}
}

impl MyTrait for int {
fn foo(&self) -> int {
return self - 2;
}
}

Yours,
  Arkadii Rost
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/rust-dev/attachments/20140702/9dc639bf/attachment.html>


More information about the Rust-dev mailing list