Guest User

Untitled

a guest
May 24th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. pub struct Struct {}
  2.  
  3. pub trait Trait<'a> {
  4. type Assoc;
  5.  
  6. fn method() -> Self::Assoc;
  7. }
  8.  
  9. impl<'a> Trait<'a> for Struct {
  10. type Assoc = ();
  11.  
  12. fn method() -> Self::Assoc {}
  13. }
  14.  
  15. pub fn function<F, T>(f: F)
  16. where
  17. F: for<'a> FnOnce(<T as Trait<'a>>::Assoc),
  18. T: for<'b> Trait<'b>,
  19. {
  20. f(T::method());
  21. }
  22.  
  23. fn main() {
  24. function::<_, Struct>(|_| {});
  25. }
Add Comment
Please, Sign In to add comment