From 4f9fe856a25ab29345b90e7725509e9ee38a37be Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:41 +0200 Subject: Adding upstream version 1.69.0+dfsg1. Signed-off-by: Daniel Baumann --- vendor/zerovec-derive/src/make_varule.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'vendor/zerovec-derive/src') diff --git a/vendor/zerovec-derive/src/make_varule.rs b/vendor/zerovec-derive/src/make_varule.rs index 7dda4932e..3220b0f8a 100644 --- a/vendor/zerovec-derive/src/make_varule.rs +++ b/vendor/zerovec-derive/src/make_varule.rs @@ -115,7 +115,6 @@ pub fn make_varule_impl(attr: AttributeArgs, mut input: DeriveInput) -> TokenStr let doc = format!("[`VarULE`](zerovec::ule::VarULE) type for {name}"); let varule_struct: DeriveInput = parse_quote!( #[repr(#repr_attr)] - #[derive(PartialEq, Eq)] #[doc = #doc] #vis struct #ule_name #field_inits #semi ); @@ -142,6 +141,19 @@ pub fn make_varule_impl(attr: AttributeArgs, mut input: DeriveInput) -> TokenStr input.span(), ); + let eq_impl = quote!( + impl core::cmp::PartialEq for #ule_name { + fn eq(&self, other: &Self) -> bool { + // The VarULE invariants allow us to assume that equality is byte equality + // in non-safety-critical contexts + ::as_byte_slice(&self) + == ::as_byte_slice(&other) + } + } + + impl core::cmp::Eq for #ule_name {} + ); + let zerofrom_fq_path = quote!(<#name as zerovec::__zerovec_internal_reexport::ZeroFrom<#ule_name>>); @@ -234,6 +246,8 @@ pub fn make_varule_impl(attr: AttributeArgs, mut input: DeriveInput) -> TokenStr #maybe_ord_impls + #eq_impl + #zmkv #maybe_ser -- cgit v1.2.3