Improved object serialization
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
|
||||
use std::{borrow::Borrow, cmp::Ordering, fmt, hash::Hash};
|
||||
|
||||
use serde::{de::DeserializeOwned, ser::SerializeMap, Deserialize, Serialize};
|
||||
use serde::{Deserialize, Serialize, de::DeserializeOwned, ser::SerializeMap};
|
||||
|
||||
// A map implemented using vectors
|
||||
// used for small datasets of less than 20 items
|
||||
@@ -56,6 +56,12 @@ impl<K: Eq + PartialEq, V> VecMap<K, V> {
|
||||
self.inner.push(KeyValue { key, value });
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn with_append(mut self, key: K, value: V) -> Self {
|
||||
self.append(key, value);
|
||||
self
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn insert(&mut self, idx: usize, key: K, value: V) {
|
||||
self.inner.insert(idx, KeyValue { key, value });
|
||||
|
||||
Reference in New Issue
Block a user