Created
May 4, 2019 00:38
-
-
Save rust-play/72c6b931fbfe5d87a12c8c1071ec3f6d to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
This file contains hidden or 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
trait Def<T> { | |
fn def(&self, foo: T) -> bool; | |
} | |
impl<T, Func> Def<T> for Func | |
where Func: Fn(T) -> bool | |
{ | |
fn def(&self, foo: T) -> bool { | |
(self)(foo) | |
} | |
} | |
fn doo(d: i32) -> bool { | |
d > 0 | |
} | |
fn main() { | |
println!("{}", doo.def(5)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment