Skip to content

Commit

Permalink
🐛 zv: Do not derive Eq for Signature
Browse files Browse the repository at this point in the history
As per [`Eq`](https://doc.rust-lang.org/stable/std/cmp/trait.Eq.html#derivable)
docs on deriving: "Note that the derive strategy requires all fields are Eq,
 which isn’t always desired."

We specify conditional `Signature` equality that does not include all
fields are (derivable) `Eq`.

Therefore this manually implements `Eq` for `Signature`.
  • Loading branch information
luukvanderduim committed Jun 27, 2023
1 parent 898cc55 commit e0f9fc1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion zvariant/src/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl<'b> std::ops::Deref for Bytes<'b> {
///
/// [identifies]: https://dbus.freedesktop.org/doc/dbus-specification.html#type-system
/// [`slice`]: #method.slice
#[derive(Eq, Hash, Clone)]
#[derive(Hash, Clone)]
pub struct Signature<'a> {
bytes: Bytes<'a>,
pos: usize,
Expand Down Expand Up @@ -392,6 +392,9 @@ impl<'a> PartialEq<&str> for Signature<'a> {
}
}

// Do not derive `Eq` if not all fields are `Eq`.
impl Eq for Signature<'_> {}

impl<'a> Display for Signature<'a> {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
std::fmt::Display::fmt(&self.as_str(), f)
Expand Down

0 comments on commit e0f9fc1

Please sign in to comment.