There aren't a lot of examples on the internet, but
how to implemenent partialeq on a vector?
how to compare vectors in the implementation?
when you can't use #[derive(PartialEq)]
how to do the following?
binary operation `==` cannot be applied to type `std::option::Option<Vec<ifwoifare_ifcalculo_ifnumerare::ifwoifis_ifcalculo_ifnumerare::ifwoifis_ifinput::IfwoifisIfinput>>`
By the way, in case you’re curious, the (default) implementation from the standard library uses something like
self.len() == other.len() && self.iter().zip(other.iter()).all(|(x, y)| x == y)
for comparing two Vecs / slices.
If you have a Vec<SomeType> containing some type that itself implements PartialEq, i.e. SomeType: PartialEq, then you can just == on the vecs. If this isn’t the case or you need some custom logic, you can try to adapt the pattern and do something other than == inside of the .all() call.
Right… make sure to click the playground link I added to my previous answer. (On the words “all the structs”.) Of course it doesn’t work if you don’t derive it for all the structs involved. Apparently your type ifwoifare_ifcalculo_ifnumerare::ifwoifis_ifcalculo_ifnumerare::ifwoifis_ifinput::IfwoifisIfinput doesn’t implement PartialEq.
the trait bound `f64: Eq` is not satisfied
--> rs/src/ifwoifare_ifcalculo_ifnumerare/ifwoifis_ifcalculo_ifnumerare/ifwoifis_ifcalculo_ifnumerare.rs:29:5
|
29 | pub ifwoifis_ifnumerus: f64,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Eq` is not implemented for `f64`
f64 doesn’t implement Eq because (NaN == NaN) returns false which violates the reflexivity (for all a: a == a) requirement of Eq.
Deriving PartialEq for your struct with an f64 field will use == on the field and in turn violate reflexivity for values containing NaN. This is the conceptual reason why the compiler will complain if you try to derive Eq. If you needEq, one reasonably approach might be in disallowing NaN values in your field by using ordered_float::NotNan<f64>,