From c5db0fefb5b2d3b1e872fb00c56186fcb2306f5d Mon Sep 17 00:00:00 2001 From: Jiahao XU Date: Thu, 28 Jul 2022 19:45:47 +1000 Subject: [PATCH] Use `Vec` for field `MetaData::other` by using `tuple_vec_map` to make the `Vec<(CompactString, serde_json::Value)>` appears as a map. This is OK because we don't access that part anyway and only add such field to avoid losing any information when deserialize, modify it and serialize it again to overwrite existing metafile. Signed-off-by: Jiahao XU --- src/metafiles/binstall_v1.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/metafiles/binstall_v1.rs b/src/metafiles/binstall_v1.rs index 35c3901a..cebdb722 100644 --- a/src/metafiles/binstall_v1.rs +++ b/src/metafiles/binstall_v1.rs @@ -1,6 +1,6 @@ use std::{ borrow, cmp, - collections::{btree_set, BTreeMap, BTreeSet}, + collections::{btree_set, BTreeSet}, hash, io::{self, Seek, Write}, iter::{IntoIterator, Iterator}, @@ -27,8 +27,8 @@ pub struct MetaData { /// Forwards compatibility. Unknown keys from future versions of Cargo /// will be stored here and retained when the file is saved. - #[serde(flatten)] - pub other: BTreeMap, + #[serde(flatten, with = "tuple_vec_map")] + pub other: Vec<(CompactString, serde_json::Value)>, } impl borrow::Borrow for MetaData {