diff options
author | Joel Galenson <jgalenson@google.com> | 2021-05-25 15:01:07 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-05-25 15:01:07 +0000 |
commit | e2a090d30261ed100b099d5640ae67e6fce7f5c5 (patch) | |
tree | 2d40aeccbf398a4c84a3ee38303459327f8d0427 | |
parent | e2a98307c4ab7f16acffaa467038291227ff12eb (diff) | |
parent | 1ee72c3be55a5bc74968f346a3cce89b66a74b0e (diff) | |
download | serde_json-e2a090d30261ed100b099d5640ae67e6fce7f5c5.tar.gz |
Upgrade rust/crates/serde_json to 1.0.64 am: 308069c537 am: 3115b28ef9 am: 1ee72c3be5
Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/serde_json/+/1712599
Change-Id: I2490411a9a99596c2d3eed10f00d66fc1c85ba60
-rw-r--r-- | .cargo_vcs_info.json | 2 | ||||
-rw-r--r-- | Android.bp | 8 | ||||
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | Cargo.toml.orig | 2 | ||||
-rw-r--r-- | METADATA | 8 | ||||
-rw-r--r-- | TEST_MAPPING | 15 | ||||
-rw-r--r-- | src/de.rs | 4 | ||||
-rw-r--r-- | src/lib.rs | 2 | ||||
-rw-r--r-- | src/map.rs | 34 | ||||
-rw-r--r-- | src/read.rs | 10 |
10 files changed, 71 insertions, 16 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index a1a51ce..dd6bf24 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,5 +1,5 @@ { "git": { - "sha1": "8d78020522b4d3001be5f9c613bf4b5a6e63618a" + "sha1": "d0d80783d31161c869922fad933b3623715506d2" } } @@ -65,7 +65,7 @@ rust_library { // proc-macro2-1.0.26 "default,proc-macro" // quote-1.0.9 "default,proc-macro" // ryu-1.0.5 -// serde-1.0.125 "default,derive,serde_derive,std" -// serde_derive-1.0.125 "default" -// syn-1.0.71 "clone-impls,default,derive,parsing,printing,proc-macro,quote" -// unicode-xid-0.2.1 "default" +// serde-1.0.126 "default,derive,serde_derive,std" +// serde_derive-1.0.126 "default" +// syn-1.0.72 "clone-impls,default,derive,parsing,printing,proc-macro,quote" +// unicode-xid-0.2.2 "default" @@ -13,7 +13,7 @@ [package] edition = "2018" name = "serde_json" -version = "1.0.62" +version = "1.0.64" authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"] include = ["build.rs", "src/**/*.rs", "README.md", "LICENSE-APACHE", "LICENSE-MIT"] description = "A JSON serialization file format" diff --git a/Cargo.toml.orig b/Cargo.toml.orig index c837c78..6ecb159 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -1,6 +1,6 @@ [package] name = "serde_json" -version = "1.0.62" # remember to update html_root_url +version = "1.0.64" # remember to update html_root_url authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"] license = "MIT OR Apache-2.0" description = "A JSON serialization file format" @@ -7,13 +7,13 @@ third_party { } url { type: ARCHIVE - value: "https://static.crates.io/crates/serde_json/serde_json-1.0.62.crate" + value: "https://static.crates.io/crates/serde_json/serde_json-1.0.64.crate" } - version: "1.0.62" + version: "1.0.64" license_type: NOTICE last_upgrade_date { year: 2021 - month: 2 - day: 9 + month: 5 + day: 19 } } diff --git a/TEST_MAPPING b/TEST_MAPPING index 22969ba..a76284a 100644 --- a/TEST_MAPPING +++ b/TEST_MAPPING @@ -2,7 +2,22 @@ { "presubmit": [ { + "name": "ZipFuseTest" + }, + { + "name": "authfs_device_test_src_lib" + }, + { + "name": "either_device_test_src_lib" + }, + { "name": "url_device_test_src_lib" + }, + { + "name": "url_device_test_tests_data" + }, + { + "name": "url_device_test_tests_unit" } ] } @@ -41,7 +41,7 @@ where /// Typically it is more convenient to use one of these methods instead: /// /// - Deserializer::from_str - /// - Deserializer::from_bytes + /// - Deserializer::from_slice /// - Deserializer::from_reader pub fn new(read: R) -> Self { Deserializer { @@ -2250,7 +2250,7 @@ where /// Typically it is more convenient to use one of these methods instead: /// /// - Deserializer::from_str(...).into_iter() - /// - Deserializer::from_bytes(...).into_iter() + /// - Deserializer::from_slice(...).into_iter() /// - Deserializer::from_reader(...).into_iter() pub fn new(read: R) -> Self { let offset = read.byte_offset(); @@ -300,7 +300,7 @@ //! [macro]: https://docs.serde.rs/serde_json/macro.json.html //! [`serde-json-core`]: https://japaric.github.io/serde-json-core/serde_json_core/ -#![doc(html_root_url = "https://docs.rs/serde_json/1.0.62")] +#![doc(html_root_url = "https://docs.rs/serde_json/1.0.64")] #![deny(clippy::all, clippy::pedantic)] // Ignored clippy lints #![allow( @@ -542,6 +542,40 @@ impl<'a> Entry<'a> { Entry::Occupied(entry) => entry.into_mut(), } } + + /// Provides in-place mutable access to an occupied entry before any + /// potential inserts into the map. + /// + /// # Examples + /// + /// ``` + /// # use serde_json::json; + /// # + /// let mut map = serde_json::Map::new(); + /// map.entry("serde") + /// .and_modify(|e| *e = json!("rust")) + /// .or_insert(json!("cpp")); + /// + /// assert_eq!(map["serde"], "cpp"); + /// + /// map.entry("serde") + /// .and_modify(|e| *e = json!("rust")) + /// .or_insert(json!("cpp")); + /// + /// assert_eq!(map["serde"], "rust"); + /// ``` + pub fn and_modify<F>(self, f: F) -> Self + where + F: FnOnce(&mut Value), + { + match self { + Entry::Occupied(mut entry) => { + f(entry.get_mut()); + Entry::Occupied(entry) + } + Entry::Vacant(entry) => Entry::Vacant(entry), + } + } } impl<'a> VacantEntry<'a> { diff --git a/src/read.rs b/src/read.rs index 522c0e0..d247c30 100644 --- a/src/read.rs +++ b/src/read.rs @@ -377,7 +377,10 @@ where V: Visitor<'de>, { let raw = self.raw_buffer.take().unwrap(); - let raw = String::from_utf8(raw).unwrap(); + let raw = match String::from_utf8(raw) { + Ok(raw) => raw, + Err(_) => return error(self, ErrorCode::InvalidUnicodeCodePoint), + }; visitor.visit_map(OwnedRawDeserializer { raw_value: Some(raw), }) @@ -587,7 +590,10 @@ impl<'a> Read<'a> for SliceRead<'a> { V: Visitor<'a>, { let raw = &self.slice[self.raw_buffering_start_index..self.index]; - let raw = str::from_utf8(raw).unwrap(); + let raw = match str::from_utf8(raw) { + Ok(raw) => raw, + Err(_) => return error(self, ErrorCode::InvalidUnicodeCodePoint), + }; visitor.visit_map(BorrowedRawDeserializer { raw_value: Some(raw), }) |