From 9062172b700aeaa780ad0a182b89dccf2e889769 Mon Sep 17 00:00:00 2001 From: Boris-Chengbiao Zhou Date: Wed, 1 Feb 2023 01:58:48 +0100 Subject: [PATCH] Implement PartialEq/Eq for Attribute Also manually implement it for Date since that is required for the derive to work. Signed-off-by: Boris-Chengbiao Zhou --- cryptoki/src/object.rs | 2 +- cryptoki/src/types.rs | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/cryptoki/src/object.rs b/cryptoki/src/object.rs index 1ec8cc7e..555ecd20 100644 --- a/cryptoki/src/object.rs +++ b/cryptoki/src/object.rs @@ -403,7 +403,7 @@ impl TryFrom for AttributeType { } } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq, Eq)] #[non_exhaustive] /// Attribute value pub enum Attribute { diff --git a/cryptoki/src/types.rs b/cryptoki/src/types.rs index 8a165fd8..b41a3c75 100644 --- a/cryptoki/src/types.rs +++ b/cryptoki/src/types.rs @@ -109,6 +109,16 @@ impl std::fmt::Display for Date { } } +impl PartialEq for Date { + fn eq(&self, other: &Self) -> bool { + self.date.year == other.date.year + && self.date.month == other.date.month + && self.date.day == other.date.day + } +} + +impl Eq for Date {} + #[derive(Debug, Copy, Clone, PartialEq, Eq)] #[repr(transparent)] /// Unsigned value, at least 32 bits long