Replace try!() with ?

This commit is contained in:
Kornel 2018-04-16 02:12:39 +01:00
parent 1272e16017
commit 6cf0d5de33
2 changed files with 4 additions and 4 deletions

View file

@ -290,7 +290,7 @@ impl<'a> Tokenizer<'a> {
val: val.into_cow(&self.input[..i]), val: val.into_cow(&self.input[..i]),
}) })
} }
Some((i, c)) => try!(new_ch(self, &mut val, multiline, i, c)), Some((i, c)) => new_ch(self, &mut val, multiline, i, c)?,
None => return Err(Error::UnterminatedString(start)) None => return Err(Error::UnterminatedString(start))
} }
} }
@ -323,7 +323,7 @@ impl<'a> Tokenizer<'a> {
Some((i, c @ 'u')) | Some((i, c @ 'u')) |
Some((i, c @ 'U')) => { Some((i, c @ 'U')) => {
let len = if c == 'u' {4} else {8}; let len = if c == 'u' {4} else {8};
val.push(try!(me.hex(start, i, len))); val.push(me.hex(start, i, len)?);
} }
Some((_, '\n')) if multi => { Some((_, '\n')) if multi => {
while let Some((_, ch)) = me.chars.clone().next() { while let Some((_, ch)) = me.chars.clone().next() {

View file

@ -445,7 +445,7 @@ impl<'de> de::Deserialize<'de> for Value {
where V: de::SeqAccess<'de>, where V: de::SeqAccess<'de>,
{ {
let mut vec = Vec::new(); let mut vec = Vec::new();
while let Some(elem) = try!(visitor.next_element()) { while let Some(elem) = visitor.next_element()? {
vec.push(elem); vec.push(elem);
} }
Ok(Value::Array(vec)) Ok(Value::Array(vec))
@ -892,7 +892,7 @@ impl ser::SerializeStruct for SerializeMap {
fn serialize_field<T: ?Sized>(&mut self, key: &'static str, value: &T) -> Result<(), ::ser::Error> fn serialize_field<T: ?Sized>(&mut self, key: &'static str, value: &T) -> Result<(), ::ser::Error>
where T: ser::Serialize where T: ser::Serialize
{ {
try!(ser::SerializeMap::serialize_key(self, key)); ser::SerializeMap::serialize_key(self, key)?;
ser::SerializeMap::serialize_value(self, value) ser::SerializeMap::serialize_value(self, value)
} }