/// a value associated with the provided key is found. If no value is found
/// or the Json value is not an Object, returns `None`.
pub fn search(&self, key: &str) -> Option<&Json> {
- match self {
- &Json::Object(ref map) => {
+ match *self {
+ Json::Object(ref map) => {
match map.get(key) {
Some(json_value) => Some(json_value),
None => {
- for (_, v) in map {
+ for v in map.values() {
match v.search(key) {
x if x.is_some() => return x,
_ => ()
}
fn parse_number(&mut self) -> JsonEvent {
- let mut neg = false;
-
- if self.ch_is('-') {
+ let neg = if self.ch_is('-') {
self.bump();
- neg = true;
- }
+ true
+ } else {
+ false
+ };
let res = match self.parse_u64() {
Ok(res) => res,
let s = self.read_str()?;
{
let mut it = s.chars();
- match (it.next(), it.next()) {
+ if let (Some(c), None) = (it.next(), it.next()) {
// exactly one character
- (Some(c), None) => return Ok(c),
- _ => ()
+ return Ok(c);
}
}
Err(ExpectedError("single character string".to_owned(), s.to_string()))