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
use core::borrow::Borrow;

use super::{Map, CollectionMut, GetMut, Insert, Remove};


pub trait MapMut<'a, K, Q, V>:
    Map<'a, K, Q, V> +
    CollectionMut +
    GetMut<&'a Q, Output = V> +
    Insert<K, V, Output = Option<V>> +
    Remove<K, Output = Option<V>> +

    where &'a Self: 'a + IntoIterator<Item = (&'a K, &'a V)>,
          &'a mut Self: 'a + IntoIterator<Item = (&'a K, &'a mut V)>,
          K: 'a + ?Sized + Borrow<Q>,
          Q: 'a + ?Sized,
          V: 'a + Sized,
{}


impl<'a, K, Q, V, T> MapMut<'a, K, Q, V> for T
    where T: 'a +
            Map<'a, K, Q, V> +
            CollectionMut +
            GetMut<&'a Q, Output = V> +
            Insert<K, V, Output = Option<V>> +
            Remove<K, Output = Option<V>>,
          &'a T: 'a + IntoIterator<Item = (&'a K, &'a V)>,
          &'a mut T: 'a + IntoIterator<Item = (&'a K, &'a mut V)>,
          K: 'a + ?Sized + Borrow<Q>,
          Q: 'a + ?Sized,
          V: 'a + Sized,
{}