pub fn read_file(path: &String) -> Result<Vec<String>, ErrorKind> {
    let file = match OpenOptions::new().read(true).open(path) {
        Err(_) => return Err(ErrorKind::FileError {
                                msg: format!("{} could not be opened", path) }),
        Ok(f) => f,
    };

    let mut reader = BufReader::new(file);
    let mut lines = Vec::new();
    let mut line = String::new();

    loop {
        match reader.read_line(&mut line) {
            Err(_) => return Err(ErrorKind::FileError {
                                msg: format!("Error while reading {}", path) }),
            Ok(len) => if len == 0 {
                break;
            },
        }
        
        line = line.replace("\n", "");
        line = line.replace("\t", "    ");
        lines.push(line.clone());
        line.clear();
    }

    Ok(lines)
}
/// Read file, remove newlines and tabs and return contents or error as Result
Read file, remove newlines and tabs and return contents or error as Result
Read file remove newlines and tabs and return contents or error as Result
pub fn read_file(path: &String) -> Result<Vec<String>, ErrorKind> {
    let file = match OpenOptions::new().read(true).open(path) {
        Err(_) => return Err(ErrorKind::FileError {
                                msg: format!("{} could not be opened", path) }),
        Ok(f) => f,
    };
    let mut reader = BufReader::new(file);
    let mut lines = Vec::new();
    let mut line = String::new();
    loop {
        match reader.read_line(&mut line) {
            Err(_) => return Err(ErrorKind::FileError {
                                msg: format!("Error while reading {}", path) }),
            Ok(len) => if len == 0 {
                break;
            },
        }
        line = line.replace("\n", "");
        line = line.replace("\t", "    ");
        lines.push(line.clone());
        line.clear();
    }
    Ok(lines)
}
pub fn read_file ( path : & String ) -> Result < Vec < String > , ErrorKind > { let file = match OpenOptions :: new ( ) . read ( true ) . open ( path ) { Err ( _ ) => return Err ( ErrorKind :: FileError { msg : format ! ( " " path ) } ) , Ok ( f ) => f , } ; let mut reader = BufReader :: new ( file ) ; let mut lines = Vec :: new ( ) ; let mut line = String :: new ( ) ; loop { match reader . read_line ( & mut line ) { Err ( _ ) => return Err ( ErrorKind :: FileError { msg : format ! ( " " path ) } ) , Ok ( len ) => if len == 0 { break ; } , } line = line . replace ( " \n " , " " ) ; line = line . replace ( " \t " , " " ) ; lines . push ( line . clone ( ) ) ; line . clear ( ) ; } Ok ( lines ) }
Read file, remove newlines and tabs and return contents or error as Result
Read file remove newlines and tabs and return contents or error as Result
path
&String