Skip to content

Instantly share code, notes, and snippets.

@aarondandy
Created October 4, 2013 06:12
Show Gist options
  • Save aarondandy/6821660 to your computer and use it in GitHub Desktop.
Save aarondandy/6821660 to your computer and use it in GitHub Desktop.
so much error...
struct Junk<T> { a: T }
impl<T:Mul<T,T>> Mul<T,Junk<T>> for Junk<T> {
fn mul(&self, rhs: &T) -> Junk<T> {
Junk{
a: self.a.mul(rhs)
}
}
}
impl<T:Mul<T,T>> Mul<Junk<T>,Junk<T>> for T {
fn mul(&self, rhs: &Junk<T>) -> Junk<T> {
Junk {
a: self.mul(&rhs.a)
}
}
}
fn main(){
let a = Junk{a: 8i} * 2i;
let b = 3i * Junk{a: 2i};
println(a.a.to_str());
println(b.a.to_str());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment