mirror of
https://github.com/guilhermewerner/reflection
synced 2025-06-16 13:34:19 +00:00
Test generics and other things
This commit is contained in:
28
Source/Examples/HashMap.rs
Normal file
28
Source/Examples/HashMap.rs
Normal 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)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user