pub fn read_to_string(filename: &str) -> Result<String, CliError> {
    let mut f = match File::open(&filename) {
        Ok(f) => f,
        Err(e) => {
            return Err(CliError {
                message: e.to_string(),
            })
        }
    };
    let metadata = fs::metadata(&filename).expect("unable to read metadata");
    let mut buffer = vec![0; metadata.len() as usize];
    if let Err(e) = f.read(&mut buffer) {
        return Err(CliError {
            message: e.to_string(),
        });
    }
    string_from_utf8(buffer)
}
/// Similar to the standard read_to_string()
/// But remove any existing BOM
Similar to the standard read_to_string()
But remove any existing BOM
Similar to the standard read_to_string () But remove any existing BOM
pub fn read_to_string(filename: &str) -> Result<String, CliError> {
    let mut f = match File::open(&filename) {
        Ok(f) => f,
        Err(e) => {
            return Err(CliError {
                message: e.to_string(),
            })
        }
    };
    let metadata = fs::metadata(&filename).expect("unable to read metadata");
    let mut buffer = vec![0; metadata.len() as usize];
    if let Err(e) = f.read(&mut buffer) {
        return Err(CliError {
            message: e.to_string(),
        });
    }
    string_from_utf8(buffer)
}
pub fn read_to_string ( filename : & str ) -> Result < String , CliError > { let mut f = match File :: open ( & filename ) { Ok ( f ) => f , Err ( e ) => { return Err ( CliError { message : e . to_string ( ) , } ) } } ; let metadata = fs :: metadata ( & filename ) . expect ( " " ) ; let mut buffer = vec ! [ 0 metadata len ( ) as usize ] ; if let Err ( e ) = f . read ( & mut buffer ) { return Err ( CliError { message : e . to_string ( ) , } ) ; } string_from_utf8 ( buffer ) }
Similar to the standard read_to_string()
But remove any existing BOM
Similar to the standard read_to_string () But remove any existing BOM
filename
&str
filename
&str