diff options
Diffstat (limited to '')
-rw-r--r-- | vendor/zerovec-derive/src/make_varule.rs | 16 |
1 files changed, 15 insertions, 1 deletions
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 + <Self as zerovec::ule::VarULE>::as_byte_slice(&self) + == <Self as zerovec::ule::VarULE>::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 |