mirror of
https://github.com/Start9Labs/patch-db.git
synced 2026-03-26 02:11:54 +00:00
MapModel for IndexMap
This commit is contained in:
committed by
Aiden McClelland
parent
df292a85d3
commit
19159746e8
@@ -16,7 +16,7 @@ version = "0.1.0"
|
||||
async-trait = "0.1.42"
|
||||
fd-lock-rs = "0.1.3"
|
||||
futures = "0.3.8"
|
||||
indexmap = "1.6.2"
|
||||
indexmap = { version = "1.6.2", features = ["serde"] }
|
||||
json-patch = { path = "../json-patch" }
|
||||
json-ptr = { path = "../json-ptr" }
|
||||
lazy_static = "1.4.0"
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::hash::Hash;
|
||||
use std::marker::PhantomData;
|
||||
use std::ops::{Deref, DerefMut};
|
||||
|
||||
use indexmap::IndexSet;
|
||||
use indexmap::{IndexMap, IndexSet};
|
||||
use json_ptr::JsonPointer;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::Value;
|
||||
@@ -385,6 +385,13 @@ impl<K: AsRef<str> + Ord, V> Map for BTreeMap<K, V> {
|
||||
self.get(key)
|
||||
}
|
||||
}
|
||||
impl<K: AsRef<str> + Eq + Hash, V> Map for IndexMap<K, V> {
|
||||
type Key = K;
|
||||
type Value = V;
|
||||
fn get(&self, key: &Self::Key) -> Option<&Self::Value> {
|
||||
IndexMap::get(self, key)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct MapModel<T>(Model<T>)
|
||||
@@ -493,3 +500,10 @@ where
|
||||
{
|
||||
type Model = MapModel<BTreeMap<K, V>>;
|
||||
}
|
||||
impl<K, V> HasModel for IndexMap<K, V>
|
||||
where
|
||||
K: Serialize + for<'de> Deserialize<'de> + Hash + Eq + AsRef<str>,
|
||||
V: Serialize + for<'de> Deserialize<'de>,
|
||||
{
|
||||
type Model = MapModel<IndexMap<K, V>>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user