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 Sponge { | |
name: String, | |
} | |
impl std::ops::Add for Sponge { | |
type Output = Self; | |
fn add(self, other: Self) -> Self { | |
Sponge { | |
name: self.name + "X" + &other.name, | |
} | |
} | |
} | |
fn main() { | |
let m1 = Sponge { | |
name: "m1".to_string(), | |
}; | |
let m2 = Sponge { | |
name: "m2".to_string(), | |
}; | |
let m3 = m1 + m2; | |
println!("{}", m3.name); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment