Created
December 22, 2014 05:54
-
-
Save michaelsproul/d094e6954567246cc0e3 to your computer and use it in GitHub Desktop.
Rust Closure Variables
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 stuff() { | |
// Split the path into its components, and make each component a path. | |
let simple_map = |comp: &str| -> Pattern { | |
Pattern::simple_pattern(comp) | |
}; | |
let glob_map = |comp: &str| -> Pattern { | |
Pattern::glob_pattern(comp) | |
}; | |
let map_fn = match prelude { | |
SimpleInclude | SimpleExclude => simple_map, | |
GlobInclude | GlobExclude => glob_map | |
}; | |
let components: Vec<Pattern> = path.split('/').map(map_fn).collect(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment