From a9eddb088a8e872c5ec1d6df091e5cbb39564915 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Mon, 21 Mar 2016 19:42:16 +0100 Subject: [PATCH] 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 --- libimagstore/src/lazyfile.rs | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-) diff --git a/libimagstore/src/lazyfile.rs b/libimagstore/src/lazyfile.rs index 59022905..0b4fa031 100644 --- a/libimagstore/src/lazyfile.rs +++ b/libimagstore/src/lazyfile.rs @@ -31,30 +31,6 @@ fn create_file>(p: A) -> ::std::io::Result { 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 */ @@ -120,7 +96,7 @@ mod test { let dir = get_dir(); let mut path = PathBuf::from(dir.path()); 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(); dir.close().unwrap(); @@ -131,7 +107,7 @@ mod test { let dir = get_dir(); let mut path = PathBuf::from(dir.path()); 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(); @@ -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(); file.read_to_end(&mut s).unwrap(); assert_eq!(s, "Hello World".to_string().into_bytes());