pub fn read_file<P: AsRef<Path>>(file: P) -> VdResult<Vec<u8>> {
    let file_name = file.as_ref().display().to_string();
    let f = File::open(file).expect(&format!("shader file '{}' not found", file_name));
    let file_bytes = f.metadata().unwrap().len() as usize;
    let mut contents = Vec::<u8>::with_capacity(file_bytes);
    let mut reader = BufReader::new(f);
    match reader.read_to_end(&mut contents) {
        Ok(bytes) => {
            assert_eq!(bytes, file_bytes);
            if PRINT { println!("Read {} bytes from {}", bytes, &file_name); }
        },
        Err(e) => panic!("{}", e),
    }
    Ok(contents)
}
/// Reads a file into a byte Vec.
Reads a file into a byte Vec.
Reads a file into a byte Vec .
pub fn read_file<P: AsRef<Path>>(file: P) -> VdResult<Vec<u8>> {
    let file_name = file.as_ref().display().to_string();
    let f = File::open(file).expect(&format!("shader file '{}' not found", file_name));
    let file_bytes = f.metadata().unwrap().len() as usize;
    let mut contents = Vec::<u8>::with_capacity(file_bytes);
    let mut reader = BufReader::new(f);
    match reader.read_to_end(&mut contents) {
        Ok(bytes) => {
            assert_eq!(bytes, file_bytes);
            if PRINT { println!("Read {} bytes from {}", bytes, &file_name); }
        },
        Err(e) => panic!("{}", e),
    }
    Ok(contents)
}
pub fn read_file < P : AsRef < Path > > ( file : P ) -> VdResult < Vec < u8 > > { let file_name = file . as_ref ( ) . display ( ) . to_string ( ) ; let f = File :: open ( file ) . expect ( & format ! ( " " file_name ) ) ; let file_bytes = f . metadata ( ) . unwrap ( ) . len ( ) as usize ; let mut contents = Vec :: < u8 > :: with_capacity ( file_bytes ) ; let mut reader = BufReader :: new ( f ) ; match reader . read_to_end ( & mut contents ) { Ok ( bytes ) => { assert_eq ! ( bytes file_bytes ) ; if PRINT { println ! ( " " bytes file_name ) ; } } , Err ( e ) => panic ! ( " " e ) , } Ok ( contents ) }
Reads a file into a byte Vec.
Reads a file into a byte Vec .
file
P
file
P