ruma_macros/serde/eq_as_ref_str.rs
1use proc_macro2::{Ident, TokenStream};
2use quote::quote;
3
4pub fn expand_partial_eq_as_ref_str(ident: &Ident) -> syn::Result<TokenStream> {
5 Ok(quote! {
6 #[automatically_derived]
7 #[allow(deprecated)]
8 impl ::std::cmp::PartialEq for #ident {
9 fn eq(&self, other: &Self) -> bool {
10 let other = ::std::convert::AsRef::<::std::primitive::str>::as_ref(other);
11 ::std::convert::AsRef::<::std::primitive::str>::as_ref(self) == other
12 }
13 }
14 })
15}