Skip to content

Instantly share code, notes, and snippets.

@berkus
Forked from rust-play/playground.rs
Created May 5, 2019 09:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save berkus/f39566858dd337feddc6bfbfed3b8830 to your computer and use it in GitHub Desktop.
Save berkus/f39566858dd337feddc6bfbfed3b8830 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