INNER CODE UNIT · Rust

silent_debug

MystenLabs/fastcrypto · fastcrypto-derive/src/lib.rs:35

pub fn silent_debug(source: TokenStream) -> TokenStream {
    let ast: DeriveInput = syn::parse(source).expect("Incorrect macro input");
    let name = &ast.ident;
    let (impl_generics, type_generics, where_clause) = &ast.generics.split_for_impl();
    let gen = quote! {
        // In order to ensure that secrets are never leaked, Debug is elided
        impl #impl_generics ::std::fmt::Debug for #name #type_generics #where_clause {
            fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
                write!(f, "<elided secret for {}>", stringify!(#name))
            }
        }
    };
    gen.into()
}

/// Extend implementations of Add, Sub, Mul<GroupElement::ScalarType> and Neg into implementations of
/// Add, Sub, Neg, AddAssign, SubAssign and MulAssign for all combinations of borrowed and owned inputs.
#[proc_macro_derive(GroupOpsExtend)]

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…