Implement serde for VecMap

This commit is contained in:
Ayaz Hafiz 2022-10-11 09:01:45 -05:00
parent a5dbdf0b02
commit e880c45c8b
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
2 changed files with 87 additions and 11 deletions

View file

@ -25,6 +25,14 @@ impl<K, V> VecMap<K, V> {
(k, v)
}
pub fn unzip(self) -> (Vec<K>, Vec<V>) {
(self.keys, self.values)
}
pub fn unzip_slices(&self) -> (&[K], &[V]) {
(&self.keys, &self.values)
}
}
impl<K: PartialEq, V> VecMap<K, V> {
@ -114,14 +122,6 @@ impl<K: PartialEq, V> VecMap<K, V> {
self.values.truncate(len);
}
pub fn unzip(self) -> (Vec<K>, Vec<V>) {
(self.keys, self.values)
}
pub fn unzip_slices(&self) -> (&[K], &[V]) {
(&self.keys, &self.values)
}
/// # Safety
///
/// keys and values must have the same length, and there must not