Skip to content

Instantly share code, notes, and snippets.

@aarondandy
Created October 6, 2013 21:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aarondandy/6859164 to your computer and use it in GitHub Desktop.
Save aarondandy/6859164 to your computer and use it in GitHub Desktop.
multiple impls
struct Junk { a: f64 }
impl Mul<Junk,Junk> for Junk {
fn mul(&self, rhs:&Junk) -> Junk {Junk{a: &self.a * rhs.a}}
}
impl Mul<f64,Junk> for Junk {
fn mul(&self, rhs:&f64) -> Junk {Junk{a: &self.a * rhs}}
}
fn main(){
println((Junk{a:2_f64} * Junk{a:3_f64}).a.to_str());
println((Junk{a:3_f64} * 4_f64).a.to_str());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment