If you do want to do this, you can wrap the type in a struct, as in:
```
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;
}
}
}
struct MyInt(int)
impl MyTrait for MyInt {
fn foo(&self) -> int {
let MyInt(i) = *self;
return i - 2;
}
}
```
Rust will optimize away the wrapper struct, so there's no overhead in doing
this.
On Tue, Jul 1, 2014 at 3:17 PM, Steve Klabnik <[email protected]>
wrote:
> You cannot.
> _______________________________________________
> 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