Test generics and other things

This commit is contained in:
Werner
2022-05-22 13:41:48 -03:00
parent acb22d7ce6
commit ced258e5c5
16 changed files with 283 additions and 32 deletions

View File

@ -0,0 +1,28 @@
use crate::*;
use std::collections::HashMap as InnerHashMap;
use std::hash::Hash;
#[derive(Reflect)]
pub struct HashMap<K, V>
where
K: Reflect + Eq + Hash,
V: Reflect,
{
inner: InnerHashMap<K, V>,
}
impl<K, V> HashMap<K, V>
where
K: Reflect + Eq + Hash,
V: Reflect,
{
#[function]
pub fn Insert(&mut self, key: K, value: V) -> Option<V> {
self.inner.insert(key, value)
}
#[function]
pub fn Remove(&mut self, key: &K) -> Option<V> {
self.inner.remove(key)
}
}