use std::env; use std::fs::File; use std::io::{self, BufRead}; use std::path::Path; fn main() { let args: Vec = env::args().collect(); let filename = parse_config(&args); if let Ok(lines) = read_lines(Path::new(filename)) { // Consumes the iterator, returns an (Optional) String for line in lines { if let Ok(ip) = line { println!("{}", ip); } } } } fn parse_config(args: &[String]) -> &str { let filename = &args[1]; filename } // The output is wrapped in a Result to allow matching on errors // Returns an Iterator to the Reader of the lines of the file. fn read_lines

(filename: P) -> io::Result>> where P: AsRef, { let file = File::open(filename)?; Ok(io::BufReader::new(file).lines()) }