Skip to content

Instantly share code, notes, and snippets.

Created November 13, 2016 06:01
Show Gist options
  • Save anonymous/b50f7494ad3148556b4b2fb4b9d4b49e to your computer and use it in GitHub Desktop.
Save anonymous/b50f7494ad3148556b4b2fb4b9d4b49e to your computer and use it in GitHub Desktop.
Shared via Rust Playground
// clap::Values is an iterator of &str
fn arg_to_platforms(platforms_option: Option<clap::Values>) -> Result<Vec<PlatformKind>, String> {
if let Some(platform_values) = platforms_option {
let mut platforms: Vec<PlatformKind> = vec![];
for platform in platform_values {
platforms.push(platform.parse::<PlatformKind>()?);
}
platforms.sort();
Ok(platforms)
} else {
Ok(vec![PlatformKind::Android, PlatformKind::iOS])
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment