Skip to content

Instantly share code, notes, and snippets.

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