I'm trying to write some basic generic:
pub struct MyGeneric<T> {
vec: Vec<T>
}
impl<T> MyGeneric<T> {
fn add(&mut self, item: T) {
if !self.vec.contains(&item) {
self.vec.push(item);
}
}
}
but getting an error:
priority_set.rs:23:10: 23:35 error: the trait `core::cmp::PartialEq` is not implemented for the type `T`
priority_set.rs:23 if !self.vec.contains(&item) {
^~~~~~~~~~~~~~~~~~~~~~~~~
error: aborting due to previous error
I have tried to implement PartialEq in several ways looking into API docs, but failed to find a solution by myself. I'm not very familiar with traits conception, so I need a help with it.
Thanks.