Guest User

Untitled

a guest
Sep 21st, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.26 KB | None | 0 0
  1. trait Tap {
  2. fn tap<R>(self, f: impl Fn(Self) -> R) -> R
  3. where
  4. Self: Sized;
  5. }
  6.  
  7. impl<T: Sized> Tap for T where T: Sized {
  8. fn tap<R>(self, f: impl Fn(T) -> R) -> R {
  9. f(self)
  10. }
  11. }
  12.  
  13. fn main() {
  14. println!("{:?}", " foo ".trim().tap(Some))
  15. }
Add Comment
Please, Sign In to add comment