Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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