Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Code shared from the Rust Playground
use std::ops::Sub;
struct Foo {
value: i32
}
trait MuhTrait {
fn traitfn(self, other: Self) -> Self;
}
impl MuhTrait for Foo {
fn traitfn(self, other: Self) -> Self {
other.value - self.value
}
}
impl<T> Sub<T> for T where T: MuhTrait {
fn sub(self, other: T) -> T {
other.traitfn(self)
}
}
fn main() {
println!("Hello, world!");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.