Reputation: 55
I am new to rust and I am looking to implement my hashmap in my struct like so
#[derive(Clone, Data)]
struct CheckState {
cool: String,
int_cool: i32,
hashmap_cool: HashMap<i32, String>
}
But i keep recieving the error code error[E0277]: the trait bound `HashMap<i32, std::string::String>: Data` is not satisfied
and i do not understand why and the help is not much help
the rust help
help: the following other types implement trait `Data`:
&'static str
()
(T0, T1)
(T0, T1, T2)
(T0, T1, T2, T3)
(T0, T1, T2, T3, T4)
(T0, T1, T2, T3, T4, T5)
(T0,)
and 87 others
= note: this error originates in the derive macro `Data` (in Nightly builds, run with -Z macro-backtrace for more info)
please ignore variable names they are not the same in my code
Upvotes: 2
Views: 1434
Reputation: 528
For a simple fix add:
struct CheckState {
cool: String,
int_cool: i32,
#[data(ignore)]
hashmap_cool: HashMap<i32, String>
}
See the druid documentation for a better understanding:
#[data(ignore)]
makes the generatedData::same
function skip comparing this field.
Upvotes: 3