-
Hi, How to deduplicate vector entries of a field? #[derive(Hash, PartialEq, Eq)]
struct A {
id: String,
name: String,
}
#[derive(From, Into)]
struct B(A);
impl Hash for B {
fn hash<H: Hasher>(&self, state: &mut H) {
self.0.id.hash(state);
}
}
impl PartialEq for B {
fn eq(&self, other: &Self) -> bool {
self.0.id == other.0.id
}
}
impl Eq for B {}
struct MyStruct {
#[serde_as(as = "Dedup<B>")]
a: Vec<A>,
} Any suggestions? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
Could you show what you tried so far? And please also include the serialized form of your data and how you expect the deserialized form to look like.
That is because there is no |
Beta Was this translation helpful? Give feedback.
-
Hi @jonasbb You can check this commit to see my current implementation.
must be deserialized as
|
Beta Was this translation helpful? Give feedback.
Hi @jonasbb You can check this commit to see my current implementation.
i want to deduplicate manifest catalogs by id & type when deserializing and serializing, while preserving the original order.
example:
must be deserialized as