ruma_macros/serde/
debug_as_ref_str.rs

1use proc_macro2::{Ident, TokenStream};
2use quote::quote;
3
4pub fn expand_debug_as_ref_str(ident: &Ident) -> syn::Result<TokenStream> {
5    Ok(quote! {
6        #[automatically_derived]
7        #[allow(deprecated)]
8        impl ::std::fmt::Debug for #ident {
9            fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
10                <::std::primitive::str as ::std::fmt::Debug>::fmt(
11                    ::std::convert::AsRef::<::std::primitive::str>::as_ref(self),
12                    f,
13                )
14            }
15        }
16    })
17}