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| { .map(|scmd| {
scmd.value_of("id") scmd.value_of("id")
.map(|id| { .map(|id| {
let path = build_entry_path(rt.store(), id); let path = try!(build_entry_path(rt.store(), id)
if path.is_err() { .map_err(|e| trace_error_exit(&e, 1)));
trace_error_exit(&path.unwrap_err(), 1);
}
let path = path.unwrap();
debug!("path = {:?}", path); debug!("path = {:?}", path);
rt.store() rt.store()

View file

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