diff options
| author | bors <bors@rust-lang.org> | 2019-10-02 06:08:24 +0000 | 
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-10-02 06:08:24 +0000 | 
| commit | f2023ac599c38a59f86552089e6791c5a73412d3 (patch) | |
| tree | e2ebd2336ca270269b57cc3660640339a182c0c2 /src/libserialize/json.rs | |
| parent | ff191b54cc8a95e3bfc7ae5f8f9984f934758165 (diff) | |
| parent | 0878ca51f08d20499e04feda142c5e0ab44a628b (diff) | |
| download | rust-f2023ac599c38a59f86552089e6791c5a73412d3.tar.gz rust-f2023ac599c38a59f86552089e6791c5a73412d3.zip | |
Auto merge of #64981 - tmandry:rollup-slfkhay, r=tmandry
Rollup of 11 pull requests Successful merges: - #64649 (Avoid ICE on return outside of fn with literal array) - #64722 (Make all alt builders produce parallel-enabled compilers) - #64801 (Avoid `chain()` in `find_constraint_paths_between_regions()`.) - #64805 (Still more `ObligationForest` improvements.) - #64840 (SelfProfiler API refactoring and part one of event review) - #64885 (use try_fold instead of try_for_each to reduce compile time) - #64942 (Fix clippy warnings) - #64952 (Update cargo.) - #64974 (Fix zebra-striping in generic dataflow visualization) - #64978 (Fully clear `HandlerInner` in `Handler::reset_err_count`) - #64979 (Update books) Failed merges: - #64959 (syntax: improve parameter without type suggestions) r? @ghost
Diffstat (limited to 'src/libserialize/json.rs')
| -rw-r--r-- | src/libserialize/json.rs | 21 | 
1 files changed, 10 insertions, 11 deletions
| diff --git a/src/libserialize/json.rs b/src/libserialize/json.rs index d0007074a82..d2e360f5e20 100644 --- a/src/libserialize/json.rs +++ b/src/libserialize/json.rs @@ -1053,12 +1053,12 @@ impl Json { /// 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, _ => () @@ -1487,12 +1487,12 @@ impl<T: Iterator<Item=char>> Parser<T> { } 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, @@ -2162,10 +2162,9 @@ impl crate::Decoder for Decoder { 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())) | 
