Skip to content

Instantly share code, notes, and snippets.

@timofurrer
Created February 25, 2019 20:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timofurrer/4953809d97fb940d0e269435192b67e2 to your computer and use it in GitHub Desktop.
Save timofurrer/4953809d97fb940d0e269435192b67e2 to your computer and use it in GitHub Desktop.
#[derive(Debug)]
struct Attribute<'a> {
name: &'a str,
url: &'a str,
}
fn main() {
let attributes = vec![
Attribute {
name: "Batman",
url: "batman.com",
},
Attribute {
name: "Robin",
url: "robin.com",
},
];
let attribute = attributes.iter().find(|&a| a.name == "Batman");
println!("Found {:?}", attribute);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment