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 <Jiahao_XU@outlook.com>
This commit is contained in:
Jiahao XU 2022-07-28 19:45:47 +10:00
parent 4ad8e4f46e
commit c5db0fefb5
No known key found for this signature in database
GPG key ID: 591C0B03040416D6

View file

@ -1,6 +1,6 @@
use std::{ use std::{
borrow, cmp, borrow, cmp,
collections::{btree_set, BTreeMap, BTreeSet}, collections::{btree_set, BTreeSet},
hash, hash,
io::{self, Seek, Write}, io::{self, Seek, Write},
iter::{IntoIterator, Iterator}, iter::{IntoIterator, Iterator},
@ -27,8 +27,8 @@ pub struct MetaData {
/// Forwards compatibility. Unknown keys from future versions of Cargo /// Forwards compatibility. Unknown keys from future versions of Cargo
/// will be stored here and retained when the file is saved. /// will be stored here and retained when the file is saved.
#[serde(flatten)] #[serde(flatten, with = "tuple_vec_map")]
pub other: BTreeMap<CompactString, serde_json::Value>, pub other: Vec<(CompactString, serde_json::Value)>,
} }
impl borrow::Borrow<str> for MetaData { impl borrow::Borrow<str> for MetaData {