In contrast to normal (non-generic) structs, generic structs which contain BiMap fail deriving and lead to compile error: "`std::cmp::Eq` is not implemented for `K`" etc. (I'm using bimap 0.5.2)
use bimap::BiMap;
#[derive(Debug)] // ok
struct NonGenericStruct {
map1: BiMap<usize, i32>,
map2: BiMap<usize, i32>,
}
#[derive(Debug)] // ERROR: e.g. "`std::cmp::Eq` is not implemented for `K`"
struct GenericStruct<K, V> {
map1: BiMap<K, V>,
map2: BiMap<K, V>,
}
fn main() {
let mut map1 = BiMap::new();
map1.insert(1usize, -1i32);
map1.insert(2, -2);
let mut map2 = BiMap::new();
map2.insert(10usize, -10i32);
let s1 = NonGenericStruct {
map1: map1.clone(),
map2: map2.clone(),
};
let s2 = GenericStruct {
map1: map1.clone(),
map2: map2.clone(),
};
println!("s1 = {:?}", s1); // ok
println!("s2 = {:?}", s2); // ERROR because `derive(Debug)` fails
}
Some trait bounds in impl<...> Debug for BiHashMap<...> seem unnecessary to implement Debug. I think this prevents #[derive(Debug)].
impl<L, R, LS, RS> fmt::Debug for BiHashMap<L, R, LS, RS>
where
L: fmt::Debug + Eq + Hash,
// ^^^^^^^^^ this seems unnecessary to implement Debug
R: fmt::Debug + Eq + Hash,
// ^^^^^^^^^ this seems unnecessary to implement Debug
{
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
...
}
}
Can you remove these trait bounds? I think this improves usability furthermore.
In contrast to normal (non-generic) structs, generic structs which contain
BiMap
fail deriving and lead to compile error: "`std::cmp::Eq` is not implemented for `K`" etc. (I'm using bimap 0.5.2)Some trait bounds in
impl<...> Debug for BiHashMap<...>
seem unnecessary to implementDebug
. I think this prevents#[derive(Debug)]
.Can you remove these trait bounds? I think this improves usability furthermore.