Skip to content

Instantly share code, notes, and snippets.

@mpfund
Created December 12, 2014 12:46
Show Gist options
  • Save mpfund/f113cac287b6ae4cab7c to your computer and use it in GitHub Desktop.
Save mpfund/f113cac287b6ae4cab7c to your computer and use it in GitHub Desktop.
Read Line from stdin and check if vector contains
use std::io;
fn main() {
let modules : Vec<&str> = vec!("a","dust","c");
let m = modules.as_slice();
let mut reader = io::stdin();
let inp = reader.read_line().ok().expect("Failed to read line");
if m.contains(&inp.trim()){
println!("true");
} else {
println!("false");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment