Use the magic of the 'From' trait

This commit is contained in:
Timothy Warren 2020-02-12 09:12:00 -05:00
parent 97bfd16b32
commit 41a33ba66f

View File

@ -296,7 +296,7 @@ impl JSON {
// Move to the next character: '}' // Move to the next character: '}'
self.increment(1); self.increment(1);
Ok(Some(JSONValue::Object(result))) Ok(Some(JSONValue::from(result)))
} }
/// See if there's a `JSONValue::Array` next in the JSON /// See if there's a `JSONValue::Array` next in the JSON
@ -325,7 +325,7 @@ impl JSON {
// move to next character: ']' // move to next character: ']'
self.increment(1); self.increment(1);
Ok(Some(JSONValue::Array(result))) Ok(Some(JSONValue::from(result)))
} }
/// See if there's a `JSONValue::String` next in the JSON /// See if there's a `JSONValue::String` next in the JSON
@ -385,7 +385,7 @@ impl JSON {
self.eat('"')?; self.eat('"')?;
Ok(Some(JSONValue::String(result))) Ok(Some(JSONValue::from(result)))
} }
/// See if there's a `JSONValue::Number` next in the JSON /// See if there's a `JSONValue::Number` next in the JSON