Created
March 20, 2019 02:41
-
-
Save rust-play/92fa096554c2282b9ebcb7346840c70a to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
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
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