Replace unwrap() with match

This commit is contained in:
Matthias Beyer 2016-08-03 11:33:13 +02:00
parent 76d88e46ad
commit bd085b0ead
2 changed files with 6 additions and 10 deletions

View file

@ -12,11 +12,8 @@ pub fn retrieve(rt: &Runtime) {
.map(|scmd| {
scmd.value_of("id")
.map(|id| {
let path = build_entry_path(rt.store(), id);
if path.is_err() {
trace_error_exit(&path.unwrap_err(), 1);
}
let path = path.unwrap();
let path = try!(build_entry_path(rt.store(), id)
.map_err(|e| trace_error_exit(&e, 1)));
debug!("path = {:?}", path);
rt.store()

View file

@ -12,11 +12,10 @@ pub fn update(rt: &Runtime) {
.map(|scmd| {
scmd.value_of("id")
.map(|id| {
let path = build_entry_path(rt.store(), id);
if path.is_err() {
trace_error_exit(&path.unwrap_err(), 1);
}
let path = path.unwrap();
let path = match build_entry_path(rt.store(), id) {
Err(e) => trace_error_exit(&e, 1),
Ok(p) => p,
};
rt.store()
.retrieve(path)