Last active
January 31, 2021 05:40
-
-
Save grahamking/1fb8c8b9c777d8b2850e519c3ec31909 to your computer and use it in GitHub Desktop.
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