1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
use std::{
    borrow::Borrow,
    collections::{HashMap,hash_map::RandomState},
    cmp::{Eq,PartialEq},
    fmt::{self,Debug},
    hash::{Hash,Hasher,BuildHasher},
    ops::{Index,IndexMut},
    iter::FromIterator,
    ptr::NonNull,
    marker::PhantomData,
    mem,
};

#[allow(unused_imports)]
use core_extensions::prelude::*;

use crate::{
    DynTrait,
    StableAbi,
    marker_type::{ErasedObject,NotCopyNotClone,UnsafeIgnoredType},
    erased_types::trait_objects::HasherObject,
    prefix_type::{PrefixTypeTrait,WithMetadata},
    std_types::*,
    traits::{IntoReprRust,ErasedType},
    utils::{transmute_reference,transmute_mut_reference},
};


mod entry;
mod extern_fns;
mod iterator_stuff;
mod map_query;
mod map_key;

#[cfg(test)]
mod test;

use self::{
    map_query::MapQuery,
    map_key::MapKey,
    entry::{BoxedREntry},
};

pub use self::{
    iterator_stuff::{
        RefIterInterface,MutIterInterface,ValIterInterface,
        IntoIter,
    },
    entry::{REntry,ROccupiedEntry,RVacantEntry},
};


/**

An ffi-safe hashmap,which wraps `std::collections::HashMap<K,V,S>`,
only requiring the `K:Eq+Hash` bounds when constructing it.

Most of the API in `HashMap` is implemented here,including the Entry API.

*/
#[derive(StableAbi)]
#[repr(C)]
#[sabi(
    inside_abi_stable_crate,
    // The hasher doesn't matter
    unconstrained(S),
)]
pub struct RHashMap<K,V,S=RandomState>{
    map:RBox<ErasedMap<K,V,S>>,
    vtable:*const VTable<K,V,S>,
}


///////////////////////////////////////////////////////////////////////////////


struct BoxedHashMap<'a,K,V,S>{
    map:HashMap<MapKey<K>,V,S>,
    entry:Option<BoxedREntry<'a,K,V>>,
}

/// An RHashMap iterator,
/// implementing `Iterator<Item= Tuple2< &K, &V > >+!Send+!Sync+Clone`
pub type Iter<'a,K,V>=
    DynTrait<'a,RBox<()>,RefIterInterface<K,V>>;

/// An RHashMap iterator,
/// implementing `Iterator<Item= Tuple2< &K, &mut V > >+!Send+!Sync`
pub type IterMut<'a,K,V>=
    DynTrait<'a,RBox<()>,MutIterInterface<K,V>>;

/// An RHashMap iterator,
/// implementing `Iterator<Item= Tuple2< K, V > >+!Send+!Sync`
pub type Drain<'a,K,V>=
    DynTrait<'a,RBox<()>,ValIterInterface<K,V>>;


/// Used as the erased type of the RHashMap type.
#[repr(C)]
#[derive(StableAbi)]
#[sabi(
    inside_abi_stable_crate,
    // The hasher doesn't matter
    unconstrained(S),
)]
struct ErasedMap<K,V,S>(
    PhantomData<Tuple2<K,V>>,
    UnsafeIgnoredType<S>
);

unsafe impl<'a,K:'a,V:'a,S:'a> ErasedType<'a> for ErasedMap<K,V,S> {
    type Unerased=BoxedHashMap<'a,K,V,S>;
}


///////////////////////////////////////////////////////////////////////////////


impl<K,V> RHashMap<K,V,RandomState>{
    /// Constructs an empty RHashMap.
    #[inline]
    pub fn new()->RHashMap<K,V>
    where 
        Self:Default
    {
        Self::default()
    }

    /// Constructs an empty RHashMap with the passed capacity.
    #[inline]
    pub fn with_capacity(capacity:usize)->RHashMap<K,V>
    where 
        Self:Default
    {
        let mut this=Self::default();
        this.reserve(capacity);
        this
    }
}


impl<K,V,S> RHashMap<K,V,S>{
    /// Constructs an empty RHashMap with the passed `hash_builder` to hash the keys.
    #[inline]
    pub fn with_hasher(hash_builder: S) -> RHashMap<K, V, S> 
    where
        K:Eq+Hash,
        S:BuildHasher+Default,
    {
        Self::with_capacity_and_hasher(0,hash_builder)
    }
    /// Constructs an empty RHashMap with the passed capacity,
    /// and the passed `hash_builder` to hash the keys.
    pub fn with_capacity_and_hasher(
        capacity: usize,
        hash_builder: S
    ) -> RHashMap<K, V, S> 
    where
        K:Eq+Hash,
        S:BuildHasher+Default,
    {
        let mut map=VTable::<K,V,S>::erased_map(hash_builder);
        map.reserve(capacity);
        RHashMap{
            map,
            vtable:unsafe{
                (*VTable::VTABLE_REF).as_prefix_raw()
            },
        }
    }
}


impl<K,V,S> RHashMap<K,V,S>{

    fn vtable<'a>(&self)->&'a VTable<K,V,S>{
        unsafe{ 
            &*self.vtable
        }
    }

}


impl<K,V,S> RHashMap<K,V,S>{
    /// Returns whether the map associates a value with the key.
    pub fn contains_key<Q>(&self,query:&Q)->bool
    where
        K:Borrow<Q>,
        Q:Hash+Eq+?Sized
    {
        self.get(query).is_some()
    }

    /// Returns a reference to the value associated with the key.
    pub fn get<Q>(&self,query:&Q)->Option<&V>
    where
        K:Borrow<Q>,
        Q:Hash+Eq+?Sized
    {
        let vtable=self.vtable();
        unsafe{
            vtable.get_elem()(&*self.map,MapQuery::new(&query))
        }
    }

    /// Returns a mutable reference to the value associated with the key.
    pub fn get_mut<Q>(&mut self,query:&Q)->Option<&mut V>
    where
        K:Borrow<Q>,
        Q:Hash+Eq+?Sized
    {
        let vtable=self.vtable();
        unsafe{
            vtable.get_mut_elem()(&mut *self.map,MapQuery::new(&query))
        }
    }

    /// Removes the value associated with the key.
    pub fn remove<Q>(&mut self,query:&Q)->ROption<V>
    where
        K:Borrow<Q>,
        Q:Hash+Eq+?Sized
    {
        self.remove_entry(query).map(|x| x.1 )
    }

    /// Removes the entry for the key.
    pub fn remove_entry<Q>(&mut self,query:&Q)->ROption<Tuple2<K,V>>
    where
        K:Borrow<Q>,
        Q:Hash+Eq+?Sized
    {
        let vtable=self.vtable();
        vtable.remove_entry()(&mut *self.map,MapQuery::new(&query))
    }
}


impl<K,V,S> RHashMap<K,V,S>{
    /// Returns whether the map associates a value with the key.
    pub fn contains_key_p(&self,key:&K)->bool{
        self.get_p(key).is_some()
    }

    /// Returns a reference to the value associated with the key.
    pub fn get_p(&self,key:&K)->Option<&V>{
        let vtable=self.vtable();
        unsafe{
            vtable.get_elem_p()(&*self.map,&key)
        }
    }

    /// Returns a mutable reference to the value associated with the key.
    pub fn get_mut_p(&mut self,key:&K)->Option<&mut V>{
        let vtable=self.vtable();
        unsafe{
            vtable.get_mut_elem_p()(&mut *self.map,&key)
        }
    }

    /// Removes the entry for the key.
    pub fn remove_entry_p(&mut self,key:&K)->ROption<Tuple2<K,V>>{
        let vtable=self.vtable();
        vtable.remove_entry_p()(&mut *self.map,&key)
    }

    /// Removes the value associated with the key.
    pub fn remove_p(&mut self,key:&K)->ROption<V>{
        self.remove_entry_p(key).map(|x| x.1 )
    }

    /// Returns a reference to the value associated with the key.
    ///
    /// # Panics
    ///
    /// Panics if the key is not associated with a value.
    pub fn index_p(&self,key:&K)->&V{
        self.get_p(key).expect("no entry in RHashMap<_,_> found for key")
    }

    /// Returns a mutable reference to the value associated with the key.
    ///
    /// # Panics
    ///
    /// Panics if the key is not associated with a value.
    pub fn index_mut_p(&mut self,key:&K)->&mut V{
        self.get_mut_p(key).expect("no entry in RHashMap<_,_> found for key")
    }

    //////////////////////////////////

    /// Inserts a value into the map,associating it with a key,returning the previous value.
    pub fn insert(&mut self,key:K,value:V)->ROption<V>{
        let vtable=self.vtable();
        unsafe{
            vtable.insert_elem()(&mut *self.map,key,value)
        }
    }

    /// Reserves enough space to insert `reserved` extra elements.
    pub fn reserve(&mut self,reserved:usize){
        let vtable=self.vtable();

        vtable.reserve()(&mut *self.map,reserved);
    }

    /// Removes all the entries in the map.
    pub fn clear(&mut self){
        let vtable=self.vtable();
        vtable.clear_map()(&mut *self.map);
    }

    /// Returns the ammount of entries in the map.
    pub fn len(&self)->usize{
        let vtable=self.vtable();
        vtable.len()(&*self.map)
    }

    /// Returns the capacity of the map,the ammount of elements it can store without reallocating.
    ///
    /// Note that this is a lower bound,since hash maps don't necessarily have an exact capacity.
    pub fn capacity(&self)->usize{
        let vtable=self.vtable();
        vtable.capacity()(&*self.map)
    }

    /// Returns whether the map contains any entries.
    pub fn is_empty(&self)->bool{
        self.len()==0
    }

    /// Iterates over the entries in the map,with references to the values in the map.
    ///
    /// This returns an `Iterator<Item= Tuple2< &K, &V > >+!Send+!Sync+Clone`
    pub fn iter    (&self)->Iter<'_,K,V>{
        let vtable=self.vtable();

        vtable.iter()(&*self.map)
    }
    
    /// Iterates over the entries in the map,with mutable references to the values in the map.
    ///
    /// This returns an `Iterator<Item= Tuple2< &K, &mut V > >+!Send+!Sync`
    pub fn iter_mut(&mut self)->IterMut<'_,K,V>{
        let vtable=self.vtable();

        vtable.iter_mut()(&mut *self.map)
    }

    /// Clears the map,returning an iterator over all the entries that were removed.
    /// 
    /// This returns an `Iterator<Item= Tuple2< K, V > >+!Send+!Sync`
    pub fn drain   (&mut self)->Drain<'_,K,V>{
        let vtable=self.vtable();

        vtable.drain()(&mut *self.map)
    }

    /// Gets a handle into the entry in the map for the key,
    /// that allows operating directly on the entry.
    pub fn entry(&mut self,key:K)->REntry<'_,K,V>{
        let vtable=self.vtable();

        vtable.entry()(&mut *self.map,key)
    }
}


/// This returns an `Iterator<Item= Tuple2< K, V > >+!Send+!Sync`
impl<K,V,S> IntoIterator for RHashMap<K,V,S>{
    type Item=Tuple2<K,V>;
    type IntoIter=IntoIter<K,V>;
    
    fn into_iter(self)->IntoIter<K,V>{
        let vtable=self.vtable();

        vtable.iter_val()(self.map)
    }
}


/// This returns an `Iterator<Item= Tuple2< &K, &V > >+!Send+!Sync+Clone`
impl<'a,K,V,S> IntoIterator for &'a RHashMap<K,V,S>{
    type Item=Tuple2<&'a K,&'a V>;
    type IntoIter=Iter<'a,K,V>;
    
    fn into_iter(self)->Self::IntoIter{
        self.iter()
    }
}


/// This returns an `Iterator<Item= Tuple2< &K, &mut V > >+!Send+!Sync`
impl<'a,K,V,S> IntoIterator for &'a mut RHashMap<K,V,S>{
    type Item=Tuple2<&'a K,&'a mut V>;
    type IntoIter=IterMut<'a,K,V>;
    
    fn into_iter(self)->Self::IntoIter{
        self.iter_mut()
    }
}


impl<K,V,S> From<HashMap<K,V,S>> for RHashMap<K,V,S>
where
    Self:Default
{
    fn from(map:HashMap<K,V,S>)->Self{
        map.into_iter().collect()
    }
}

impl<K,V,S> Into<HashMap<K,V,S>> for RHashMap<K,V,S>
where
    K:Eq+Hash,
    S:BuildHasher+Default,
{
    fn into(self)->HashMap<K,V,S>{
        self.into_iter().map(IntoReprRust::into_rust).collect()
    }
}


impl<K,V,S> FromIterator<(K,V)> for RHashMap<K,V,S>
where
    Self:Default,
{
    fn from_iter<I>(iter: I) -> Self
    where
        I: IntoIterator<Item = (K,V)>
    {
        let mut map=Self::default();
        map.extend(iter);
        map
    }
}


impl<K,V,S> FromIterator<Tuple2<K,V>> for RHashMap<K,V,S>
where
    Self:Default
{
    fn from_iter<I>(iter: I) -> Self
    where
        I: IntoIterator<Item = Tuple2<K,V>>
    {
        let mut map=Self::default();
        map.extend(iter);
        map
    }
}


impl<K,V,S> Extend<(K,V)> for RHashMap<K,V,S>{
    fn extend<I>(&mut self,iter: I)
    where
        I: IntoIterator<Item = (K,V)>
    {
        let iter=iter.into_iter();
        self.reserve(iter.size_hint().0);
        for (k,v) in iter {
            self.insert(k,v);
        }
    }
}


impl<K,V,S> Extend<Tuple2<K,V>> for RHashMap<K,V,S>{
    #[inline]
    fn extend<I>(&mut self,iter: I)
    where
        I: IntoIterator<Item = Tuple2<K,V>>
    {
        self.extend( iter.into_iter().map(Tuple2::into_rust) );
    }
}

impl<K,V,S> Default for RHashMap<K,V,S>
where
    K:Eq+Hash,
    S:BuildHasher+Default,
{
    fn default()->Self{
        Self::with_hasher(S::default())
    }
}


impl<K,V,S> Clone for RHashMap<K,V,S>
where 
    K:Clone,
    V:Clone,
    Self:Default
{
    fn clone(&self)->Self{
        self.iter().map(|Tuple2(k,v)| (k.clone(),v.clone()) ).collect()
    }
}


impl<K,V,S> Debug for RHashMap<K,V,S>
where 
    K:Debug,
    V:Debug,
{
    fn fmt(&self,f:&mut fmt::Formatter<'_>)->fmt::Result{
        f.debug_map()
         .entries(self.iter().map(Tuple2::into_rust))
         .finish()
    }
}


impl<K,V,S> Eq for RHashMap<K,V,S>
where 
    K:Eq,
    V:Eq,
{}


impl<K,V,S> PartialEq for RHashMap<K,V,S>
where 
    K:PartialEq,
    V:PartialEq,
{
    fn eq(&self,other:&Self)->bool{
        if self.len() != other.len() {
            return false;
        }

        self.iter()
            .all(|Tuple2(k, vl)|{
                other.get_p(k)
                     .map_or(false, |vr| *vr == *vl)
            })
    }
}


unsafe impl<K, V, S> Send for RHashMap<K, V, S> 
where
    HashMap<K, V, S>: Send,
{}

unsafe impl<K, V, S> Sync for RHashMap<K, V, S> 
where
    HashMap<K, V, S>: Sync,
{}


impl<K,Q,V,S> Index<&Q> for RHashMap<K,V,S>
where
    K:Borrow<Q>,
    Q:Eq+Hash
{
    type Output=V;

    fn index(&self,query:&Q)->&V{
        self.get(query).expect("no entry in RHashMap<_,_> found for key")
    }
}

impl<K,Q,V,S> IndexMut<&Q> for RHashMap<K,V,S>
where
    K:Borrow<Q>,
    Q:Eq+Hash
{
    fn index_mut(&mut self,query:&Q)->&mut V{
        self.get_mut(query).expect("no entry in RHashMap<_,_> found for key")
    }
}


mod serde{
    use super::*;

    use ::serde::{
        de::{Visitor, MapAccess},
        ser::SerializeMap,
        Deserialize,Serialize,Deserializer,Serializer,
    };


    struct RHashMapVisitor<K,V,S> {
        marker: PhantomData<fn() -> RHashMap<K,V,S>>
    }

    impl<K,V,S> RHashMapVisitor<K,V,S> {
        fn new() -> Self {
            RHashMapVisitor {
                marker: PhantomData
            }
        }
    }

    impl<'de,K,V,S> Visitor<'de> for RHashMapVisitor<K,V,S>
    where
        K: Deserialize<'de>,
        V: Deserialize<'de>,
        RHashMap<K,V,S>:Default,
    {
        type Value = RHashMap<K,V,S>;

        fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
            formatter.write_str("an RHashMap")
        }

        fn visit_map<M>(self, mut map_access: M) -> Result<Self::Value, M::Error>
        where
            M: MapAccess<'de>,
        {
            let capacity=map_access.size_hint().unwrap_or(0);
            let mut map = RHashMap::default();
            map.reserve(capacity);

            while let Some((k, v)) = map_access.next_entry()? {
                map.insert(k, v);
            }

            Ok(map)
        }
    }

    impl<'de,K,V,S> Deserialize<'de> for RHashMap<K,V,S>
    where
        K: Deserialize<'de>,
        V: Deserialize<'de>,
        Self:Default,
    {
        fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
        where
            D: Deserializer<'de>,
        {
            deserializer.deserialize_map(RHashMapVisitor::new())
        }
    }

    

    impl<K,V,S> Serialize for RHashMap<K,V,S>
    where
        K:Serialize,
        V:Serialize,
    {
        fn serialize<Z>(&self, serializer: Z) -> Result<Z::Ok, Z::Error>
        where
            Z: Serializer
        {
            let mut map = serializer.serialize_map(Some(self.len()))?;
            for Tuple2(k, v) in self.iter() {
                map.serialize_entry(k, v)?;
            }
            map.end()
        }
    }


}


///////////////////////////////////////////////////////////////////////////////


#[derive(StableAbi)]
#[repr(C)]
#[sabi(
    inside_abi_stable_crate,
    kind(Prefix(prefix_struct="VTable")),
    missing_field(panic),
    // The hasher doesn't matter
    unconstrained(S),
)]
struct VTableVal<K,V,S>{
    insert_elem:extern fn(&mut ErasedMap<K,V,S>,K,V)->ROption<V>,
    
    get_elem:for<'a> extern fn(&'a ErasedMap<K,V,S>,MapQuery<'_,K>)->Option<&'a V>,
    get_mut_elem:for<'a> extern fn(&'a mut ErasedMap<K,V,S>,MapQuery<'_,K>)->Option<&'a mut V>,
    remove_entry:extern fn(&mut ErasedMap<K,V,S>,MapQuery<'_,K>)->ROption<Tuple2<K,V>>,
    
    get_elem_p:for<'a> extern fn(&'a ErasedMap<K,V,S>,&K)->Option<&'a V>,
    get_mut_elem_p:for<'a> extern fn(&'a mut ErasedMap<K,V,S>,&K)->Option<&'a mut V>,
    remove_entry_p:extern fn(&mut ErasedMap<K,V,S>,&K)->ROption<Tuple2<K,V>>,
    
    reserve:extern fn(&mut ErasedMap<K,V,S>,usize),
    clear_map:extern fn(&mut ErasedMap<K,V,S>),
    len:extern fn(&ErasedMap<K,V,S>)->usize,
    capacity:extern fn(&ErasedMap<K,V,S>)->usize,
    iter    :extern fn(&ErasedMap<K,V,S>     )->Iter<'_,K,V>,
    iter_mut:extern fn(&mut ErasedMap<K,V,S> )->IterMut<'_,K,V>,
    drain   :extern fn(&mut ErasedMap<K,V,S> )->Drain<'_,K,V>,
    iter_val:extern fn(RBox<ErasedMap<K,V,S>>)->IntoIter<K,V>,
    #[sabi(last_prefix_field)]
    entry:extern fn(&mut ErasedMap<K,V,S>,K)->REntry<'_,K,V>,
}



impl<K,V,S> VTable<K,V,S>
where
    K:Eq+Hash,
    S:BuildHasher,
{
    const VTABLE_REF: *const WithMetadata<VTableVal<K,V,S>> = {
        &WithMetadata::new(PrefixTypeTrait::METADATA,Self::VTABLE)
    };

    fn erased_map(hash_builder:S)->RBox<ErasedMap<K,V,S>>{
        unsafe{
            let map=HashMap::<MapKey<K>,V,S>::with_hasher(hash_builder);
            let boxed=BoxedHashMap{
                map,
                entry:None,
            };
            let boxed=RBox::new(boxed);
            let boxed=mem::transmute::<RBox<_>,RBox<ErasedMap<K,V,S>>>(boxed);
            boxed
        }
    }


    const VTABLE:VTableVal<K,V,S>=VTableVal{
        insert_elem :ErasedMap::insert_elem,

        get_elem    :ErasedMap::get_elem,
        get_mut_elem:ErasedMap::get_mut_elem,
        remove_entry:ErasedMap::remove_entry,

        get_elem_p    :ErasedMap::get_elem_p,
        get_mut_elem_p:ErasedMap::get_mut_elem_p,
        remove_entry_p:ErasedMap::remove_entry_p,

        reserve     :ErasedMap::reserve,
        clear_map   :ErasedMap::clear_map,
        len         :ErasedMap::len,
        capacity    :ErasedMap::capacity,
        iter        :ErasedMap::iter,
        iter_mut    :ErasedMap::iter_mut,
        drain       :ErasedMap::drain,
        iter_val    :ErasedMap::iter_val,
        entry       :ErasedMap::entry,
    };

}



///////////////////////////////////////////////////////////////////////////////