use std::io;
use std::io::{Read, Write};
use std::fs::File;


pub fn write_file(filename: &str, contents: &Vec<u8>) -> io::Result<()> {
    let mut file = try!(File::create(filename));
    Ok(try!(file.write_all(contents)))
}


pub fn read_file_to_string(filename: &str, buf: &mut String) -> io::Result<usize> {
    let mut file = try!(File::open(filename));
    let bytes = try!(file.read_to_string(buf));
    Ok(bytes)
}

use std::io;
use std::io::{Read, Write};
use std::fs::File;
use std::path::Path;


pub fn write_file<P: AsRef<Path>>(path: P, contents: &Vec<u8>) -> io::Result<()> {
    let mut file = try!(File::create(path));
    Ok(try!(file.write_all(contents)))
}


pub fn read_file_to_string<P: AsRef<Path>>(path: P, buf: &mut String) -> io::Result<usize> {
    let mut file = try!(File::open(path));
    let bytes = try!(file.read_to_string(buf));
    Ok(bytes)
}

Make read_file and write_file take generic paths
Make read_file and write_file take generic paths
