Skip to content

Instantly share code, notes, and snippets.

@rust-play
Created May 4, 2019 00:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rust-play/72c6b931fbfe5d87a12c8c1071ec3f6d to your computer and use it in GitHub Desktop.
Save rust-play/72c6b931fbfe5d87a12c8c1071ec3f6d to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
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