Merge pull request #160 from mre/error-handling-unwrap

Replace unwrap with expect in public-facing code
This commit is contained in:
Alex Crichton 2017-04-05 16:49:48 -07:00 committed by GitHub
commit b3a92872a1
2 changed files with 4 additions and 4 deletions

View file

@ -285,7 +285,7 @@ impl<'a, 'b> de::MapVisitor for MapVisitor<'a, 'b> {
return Err(self.de.error(table.at, kind)) return Err(self.de.error(table.at, kind))
} }
self.values = table.values.take().unwrap().into_iter(); self.values = table.values.take().expect("Unable to read table values").into_iter();
} }
} }
@ -346,7 +346,7 @@ impl<'a, 'b> de::SeqVisitor for MapVisitor<'a, 'b> {
.unwrap_or(self.max); .unwrap_or(self.max);
let ret = seed.deserialize(MapVisitor { let ret = seed.deserialize(MapVisitor {
values: self.tables[self.cur_parent].values.take().unwrap().into_iter(), values: self.tables[self.cur_parent].values.take().expect("Unable to read table values").into_iter(),
next_value: None, next_value: None,
depth: self.depth + 1, depth: self.depth + 1,
cur_parent: self.cur_parent, cur_parent: self.cur_parent,
@ -569,7 +569,7 @@ impl<'a> de::MapVisitor for InlineTableDeserializer<'a> {
fn visit_value_seed<V>(&mut self, seed: V) -> Result<V::Value, Error> fn visit_value_seed<V>(&mut self, seed: V) -> Result<V::Value, Error>
where V: de::DeserializeSeed, where V: de::DeserializeSeed,
{ {
let value = self.next_value.take().unwrap(); let value = self.next_value.take().expect("Unable to read table values");
seed.deserialize(ValueDeserializer::new(value)) seed.deserialize(ValueDeserializer::new(value))
} }
} }

View file

@ -337,7 +337,7 @@ impl<'s, T: ?Sized> Index for &'s T where T: Index {
impl fmt::Display for Value { impl fmt::Display for Value {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
::ser::to_string(self).unwrap().fmt(f) ::ser::to_string(self).expect("Unable to represent value as string").fmt(f)
} }
} }