Advertisement
Guest User

Untitled

a guest
Jul 15th, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. struct Foobar {
  2. first: String,
  3. second: String,
  4. third: String,
  5. }
  6.  
  7. fn grab_first(foobar: &Foobar) -> &str {
  8. &foobar.first
  9. }
  10.  
  11. fn go<F>(lhs: Foobar, rhs: Foobar, f: F) -> bool
  12. where
  13. F: Fn(&Foobar) -> &str,
  14. {
  15. f(&lhs) == f(&rhs)
  16. }
  17.  
  18. fn main() {
  19. dbg!(go(
  20. Foobar {
  21. first: "alpha".to_owned(),
  22. second: "beta".to_owned(),
  23. third: "gamma".to_owned()
  24. },
  25. Foobar {
  26. first: "alpha".to_owned(),
  27. second: "delta".to_owned(),
  28. third: "epsilon".to_owned()
  29. },
  30. grab_first
  31. ));
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement