Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct Foobar {
- first: String,
- second: String,
- third: String,
- }
- fn grab_first(foobar: &Foobar) -> &str {
- &foobar.first
- }
- fn go<F>(lhs: Foobar, rhs: Foobar, f: F) -> bool
- where
- F: Fn(&Foobar) -> &str,
- {
- f(&lhs) == f(&rhs)
- }
- fn main() {
- dbg!(go(
- Foobar {
- first: "alpha".to_owned(),
- second: "beta".to_owned(),
- third: "gamma".to_owned()
- },
- Foobar {
- first: "alpha".to_owned(),
- second: "delta".to_owned(),
- third: "epsilon".to_owned()
- },
- grab_first
- ));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement