diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:41 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:41 +0000 |
commit | 4f9fe856a25ab29345b90e7725509e9ee38a37be (patch) | |
tree | e4ffd8a9374cae7b21f7cbfb352927e0e074aff6 /vendor/litemap/tests/rkyv.rs | |
parent | Adding upstream version 1.68.2+dfsg1. (diff) | |
download | rustc-upstream/1.69.0+dfsg1.tar.xz rustc-upstream/1.69.0+dfsg1.zip |
Adding upstream version 1.69.0+dfsg1.upstream/1.69.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/litemap/tests/rkyv.rs')
-rw-r--r-- | vendor/litemap/tests/rkyv.rs | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/vendor/litemap/tests/rkyv.rs b/vendor/litemap/tests/rkyv.rs index 2d6438dc7..7ab1eb3f5 100644 --- a/vendor/litemap/tests/rkyv.rs +++ b/vendor/litemap/tests/rkyv.rs @@ -41,17 +41,14 @@ type LiteMapOfStrings = LiteMap<String, String>; type TupleVecOfStrings = Vec<(String, String)>; fn generate() -> AlignedVec { - let mut map: LiteMapOfStrings = LiteMap::new(); - for (lang, name) in DATA.iter() { - map.try_append(lang.to_string(), name.to_string()) - .ok_or(()) - .unwrap_err(); - } - let tuple_vec = map.into_tuple_vec(); + let map = DATA + .iter() + .map(|&(k, v)| (k.to_owned(), v.to_owned())) + .collect::<LiteMapOfStrings>(); let mut serializer = AllocSerializer::<4096>::default(); serializer - .serialize_value(&tuple_vec) + .serialize_value(&map.into_tuple_vec()) .expect("failed to archive test"); serializer.into_serializer().into_inner() } @@ -82,5 +79,5 @@ fn rkyv_deserialize() { let deserialized = archived.deserialize(&mut Infallible).unwrap(); // Safe because we are deserializing a buffer from a trusted source let deserialized: LiteMapOfStrings = LiteMap::from_sorted_store_unchecked(deserialized); - assert_eq!(deserialized.get("tr"), Some(&"Turkish".to_string())); + assert_eq!(deserialized.get("tr").map(String::as_str), Some("Turkish")); } |