Created
April 23, 2019 20:21
-
-
Save rust-play/8eda1e8c617e5ced01079df7094db798 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() { | |
let filter = "Joh"; | |
let names = vec!["John", "Jane", "Johnny"]; | |
let lowered_filter = filter.to_lowercase(); | |
let filterNames = |x: &&str| -> bool { | |
x.to_lowercase().contains(&lowered_filter) | |
}; | |
let filtered: Vec<&str> = names.iter().cloned().filter(filterNames).collect(); | |
println!("List {:?}", filtered); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment