use std::fs::File; use std::io::{self, BufRead}; use std::path::Path; use std::string::String; fn read_lines

(filename: P) -> io::Result>> where P: AsRef, { let file = File::open(filename)?; Ok(io::BufReader::new(file).lines()) } #[derive(Debug)] pub struct Playlist { path: String, tracks: Box> } impl Playlist { pub fn read(path: &str) -> Result { let playlist_path: String = String::from(path); let mut playlist_tracks: Vec = Vec::new(); let lines = read_lines(path)?; lines.for_each(|read_line| { if read_line.is_ok() { let line = read_line.unwrap(); if line.len() > 0 && !line.starts_with("#") { playlist_tracks.push(line) } } }); Ok(Playlist { path: playlist_path, tracks: Box::new(playlist_tracks) }) } }