Do not simply unwrap, but return error in case of error

This commit is contained in:
Matthias Beyer 2016-10-11 21:17:48 +02:00
parent 17fba2c47f
commit 27e816fc69
1 changed files with 2 additions and 2 deletions

View File

@ -69,14 +69,14 @@ mod fs {
pub fn copy(from: &PathBuf, to: &PathBuf) -> Result<(), SE> {
let mut map = MAP.lock().unwrap();
let a = map.get(from).unwrap().clone();
let a = try!(map.get(from).cloned().ok_or(SEK::FileNotFound.into_error()));
map.insert(to.clone(), a);
Ok(())
}
pub fn rename(from: &PathBuf, to: &PathBuf) -> Result<(), SE> {
let mut map = MAP.lock().unwrap();
let a = map.get(from).unwrap().clone();
let a = try!(map.get(from).cloned().ok_or(SEK::FileNotFound.into_error()));
map.insert(to.clone(), a);
Ok(())
}