libimagstore: Replace .err().unwrap() with .unwrap_err()

This commit is contained in:
Matthias Beyer 2016-04-17 21:08:54 +02:00
parent 3631817827
commit 0bb40fca11

View file

@ -156,7 +156,7 @@ impl Store {
if c.is_err() { if c.is_err() {
debug!("Failed"); debug!("Failed");
return Err(StoreError::new(StoreErrorKind::StorePathCreate, return Err(StoreError::new(StoreErrorKind::StorePathCreate,
Some(Box::new(c.err().unwrap())))); Some(Box::new(c.unwrap_err()))));
} }
} else { } else {
if location.is_file() { if location.is_file() {
@ -434,7 +434,7 @@ impl Store {
if guard.is_err() { if guard.is_err() {
return Err(StoreError::new(StoreErrorKind::HookRegisterError, return Err(StoreError::new(StoreErrorKind::HookRegisterError,
Some(Box::new(guard.err().unwrap())))); Some(Box::new(guard.unwrap_err()))));
} }
let mut guard = guard.unwrap(); let mut guard = guard.unwrap();
for mut aspect in guard.deref_mut() { for mut aspect in guard.deref_mut() {
@ -764,7 +764,7 @@ impl EntryHeader {
pub fn set_with_sep(&mut self, spec: &str, sep: char, v: Value) -> Result<Option<Value>> { pub fn set_with_sep(&mut self, spec: &str, sep: char, v: Value) -> Result<Option<Value>> {
let tokens = EntryHeader::tokenize(spec, sep); let tokens = EntryHeader::tokenize(spec, sep);
if tokens.is_err() { // return parser error if any if tokens.is_err() { // return parser error if any
return Err(tokens.err().unwrap()); return Err(tokens.unwrap_err());
} }
let tokens = tokens.unwrap(); let tokens = tokens.unwrap();
debug!("tokens = {:?}", tokens); debug!("tokens = {:?}", tokens);
@ -779,7 +779,7 @@ impl EntryHeader {
let path_to_dest = tokens[..(tokens.len() - 1)].into(); // N - 1 tokens let path_to_dest = tokens[..(tokens.len() - 1)].into(); // N - 1 tokens
let value = EntryHeader::walk_header(&mut self.header, path_to_dest); // walk N-1 tokens let value = EntryHeader::walk_header(&mut self.header, path_to_dest); // walk N-1 tokens
if value.is_err() { if value.is_err() {
return Err(value.err().unwrap()); return Err(value.unwrap_err());
} }
let mut value = value.unwrap(); let mut value = value.unwrap();
debug!("walked value = {:?}", value); debug!("walked value = {:?}", value);
@ -871,14 +871,14 @@ impl EntryHeader {
pub fn read_with_sep(&self, spec: &str, splitchr: char) -> Result<Option<Value>> { pub fn read_with_sep(&self, spec: &str, splitchr: char) -> Result<Option<Value>> {
let tokens = EntryHeader::tokenize(spec, splitchr); let tokens = EntryHeader::tokenize(spec, splitchr);
if tokens.is_err() { // return parser error if any if tokens.is_err() { // return parser error if any
return Err(tokens.err().unwrap()); return Err(tokens.unwrap_err());
} }
let tokens = tokens.unwrap(); let tokens = tokens.unwrap();
let mut header_clone = self.header.clone(); // we clone as READing is simpler this way let mut header_clone = self.header.clone(); // we clone as READing is simpler this way
let value = EntryHeader::walk_header(&mut header_clone, tokens); // walk N-1 tokens let value = EntryHeader::walk_header(&mut header_clone, tokens); // walk N-1 tokens
if value.is_err() { if value.is_err() {
let e = value.err().unwrap(); let e = value.unwrap_err();
return match e.err_type() { return match e.err_type() {
// We cannot find the header key, as there is no path to it // We cannot find the header key, as there is no path to it
StoreErrorKind::HeaderKeyNotFound => Ok(None), StoreErrorKind::HeaderKeyNotFound => Ok(None),
@ -891,7 +891,7 @@ impl EntryHeader {
pub fn delete(&mut self, spec: &str) -> Result<Option<Value>> { pub fn delete(&mut self, spec: &str) -> Result<Option<Value>> {
let tokens = EntryHeader::tokenize(spec, '.'); let tokens = EntryHeader::tokenize(spec, '.');
if tokens.is_err() { // return parser error if any if tokens.is_err() { // return parser error if any
return Err(tokens.err().unwrap()); return Err(tokens.unwrap_err());
} }
let tokens = tokens.unwrap(); let tokens = tokens.unwrap();
@ -905,7 +905,7 @@ impl EntryHeader {
let path_to_dest = tokens[..(tokens.len() - 1)].into(); // N - 1 tokens let path_to_dest = tokens[..(tokens.len() - 1)].into(); // N - 1 tokens
let value = EntryHeader::walk_header(&mut self.header, path_to_dest); // walk N-1 tokens let value = EntryHeader::walk_header(&mut self.header, path_to_dest); // walk N-1 tokens
if value.is_err() { if value.is_err() {
return Err(value.err().unwrap()); return Err(value.unwrap_err());
} }
let mut value = value.unwrap(); let mut value = value.unwrap();
debug!("walked value = {:?}", value); debug!("walked value = {:?}", value);