Skip to content

Instantly share code, notes, and snippets.

@rust-play
Created January 24, 2020 13:33
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 rust-play/4f488339b804ac9bd9373fc01853c5a4 to your computer and use it in GitHub Desktop.
Save rust-play/4f488339b804ac9bd9373fc01853c5a4 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
fn identity<T: ?Sized, F>(f: F) -> F
where
F: for<'a> Fn(&'a T) -> &'a T,
{
f
}
fn foo(_f: impl for<'a> Fn(&'a str) -> &'a str) {}
fn main() {
let closure = identity(|s: &str| s);
foo(closure);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment