Created
October 6, 2013 21:10
-
-
Save aarondandy/6859164 to your computer and use it in GitHub Desktop.
multiple impls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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