Remove warnings by returning errors explicitely

This commit is contained in:
Matthias Beyer 2017-06-09 13:27:06 +02:00
parent 81449f48d6
commit bec59c1f8a
1 changed files with 13 additions and 8 deletions

View File

@ -134,8 +134,9 @@ mod fs {
.map_err_into(SEK::FileNotSeeked)); .map_err_into(SEK::FileNotSeeked));
let mut s = String::new(); let mut s = String::new();
f.read_to_string(&mut s); f.read_to_string(&mut s)
Ok(s) .map_err_into(SEK::IoError)
.map(|_| s)
}, },
FSFileAbstractionInstance::Absent(ref p) => FSFileAbstractionInstance::Absent(ref p) =>
(try!(open_file(p).map_err_into(SEK::FileNotFound)), p.clone()), (try!(open_file(p).map_err_into(SEK::FileNotFound)), p.clone()),
@ -143,10 +144,12 @@ mod fs {
*self = FSFileAbstractionInstance::File(file, path); *self = FSFileAbstractionInstance::File(file, path);
if let FSFileAbstractionInstance::File(ref mut f, _) = *self { if let FSFileAbstractionInstance::File(ref mut f, _) = *self {
let mut s = String::new(); let mut s = String::new();
f.read_to_string(&mut s); f.read_to_string(&mut s)
return Ok(s); .map_err_into(SEK::IoError)
.map(|_| s)
} else {
unreachable!()
} }
unreachable!()
} }
/** /**
@ -241,6 +244,7 @@ mod inmemory {
use super::FileAbstraction; use super::FileAbstraction;
use super::FileAbstractionInstance; use super::FileAbstractionInstance;
use error::MapErrInto;
type Backend = Arc<Mutex<RefCell<HashMap<PathBuf, Cursor<Vec<u8>>>>>>; type Backend = Arc<Mutex<RefCell<HashMap<PathBuf, Cursor<Vec<u8>>>>>>;
@ -278,10 +282,11 @@ mod inmemory {
mtx.get_mut() mtx.get_mut()
.get_mut(&p) .get_mut(&p)
.ok_or(SEK::FileNotFound.into_error()) .ok_or(SEK::FileNotFound.into_error())
.map(|t| { .and_then(|t| {
let mut s = String::new(); let mut s = String::new();
t.read_to_string(&mut s); t.read_to_string(&mut s)
s .map_err_into(SEK::IoError)
.map(|_| s)
}) })
} }