Remove unused functions from LazyFile

- Remove uses of LazyFile::new() from tests
    - Use LazyFile::get_file_mut() in test as we want the file mut anyways
This commit is contained in:
Matthias Beyer 2016-03-21 19:42:16 +01:00
parent af161394ad
commit a9eddb088a

View file

@ -31,30 +31,6 @@ fn create_file<A: AsRef<Path>>(p: A) -> ::std::io::Result<File> {
impl LazyFile { impl LazyFile {
/**
* Create a new LazyFile instance from a Path
*/
pub fn new(p: PathBuf) -> LazyFile {
LazyFile::Absent(p)
}
/**
* Create a new LazyFile instance from an already existing file
*/
pub fn new_with_file(f: File) -> LazyFile {
LazyFile::File(f)
}
/**
* Get the file behind a LazyFile object
*/
pub fn get_file(&mut self) -> Result<&File, StoreError> {
match self.get_file_mut() {
Ok(file) => Ok(&*file),
Err(e) => Err(e)
}
}
/** /**
* Get the mutable file behind a LazyFile object * Get the mutable file behind a LazyFile object
*/ */
@ -120,7 +96,7 @@ mod test {
let dir = get_dir(); let dir = get_dir();
let mut path = PathBuf::from(dir.path()); let mut path = PathBuf::from(dir.path());
path.set_file_name("test1"); path.set_file_name("test1");
let mut lf = LazyFile::new(path); let mut lf = LazyFile::Absent(path);
write!(lf.create_file().unwrap(), "Hello World").unwrap(); write!(lf.create_file().unwrap(), "Hello World").unwrap();
dir.close().unwrap(); dir.close().unwrap();
@ -131,7 +107,7 @@ mod test {
let dir = get_dir(); let dir = get_dir();
let mut path = PathBuf::from(dir.path()); let mut path = PathBuf::from(dir.path());
path.set_file_name("test2"); path.set_file_name("test2");
let mut lf = LazyFile::new(path.clone()); let mut lf = LazyFile::Absent(path.clone());
{ {
let mut file = lf.create_file().unwrap(); let mut file = lf.create_file().unwrap();
@ -141,7 +117,7 @@ mod test {
} }
{ {
let mut file = lf.get_file().unwrap(); let mut file = lf.get_file_mut().unwrap();
let mut s = Vec::new(); let mut s = Vec::new();
file.read_to_end(&mut s).unwrap(); file.read_to_end(&mut s).unwrap();
assert_eq!(s, "Hello World".to_string().into_bytes()); assert_eq!(s, "Hello World".to_string().into_bytes());