Skip to content

Commit

Permalink
adds support for re-exporting crate
Browse files Browse the repository at this point in the history
  • Loading branch information
colstrom committed Oct 30, 2024
1 parent 60393cc commit 4d98e0e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions veil-macros/src/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ pub enum RedactionLength {
impl quote::ToTokens for RedactionLength {
fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) {
match self {
RedactionLength::Full => quote! { ::veil::private::RedactionLength::Full }.to_tokens(tokens),
RedactionLength::Partial => quote! { ::veil::private::RedactionLength::Partial }.to_tokens(tokens),
RedactionLength::Full => quote! { veil::private::RedactionLength::Full }.to_tokens(tokens),
RedactionLength::Partial => quote! { veil::private::RedactionLength::Partial }.to_tokens(tokens),
RedactionLength::Fixed(n) => {
let n = n.get();
quote! { ::veil::private::RedactionLength::Fixed(::core::num::NonZeroU8::new(#n).unwrap()) }
quote! { veil::private::RedactionLength::Fixed(::core::num::NonZeroU8::new(#n).unwrap()) }
.to_tokens(tokens)
}
}
Expand Down
14 changes: 7 additions & 7 deletions veil-macros/src/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,26 +162,26 @@ pub(crate) fn generate_redact_call(
unused.redacted_something();

let specialization = if is_option {
quote! { ::std::option::Option::Some(::veil::private::RedactSpecialization::Option) }
quote! { ::std::option::Option::Some(veil::private::RedactSpecialization::Option) }
} else {
quote! { ::std::option::Option::None }
};

if field_flags.display {
// std::fmt::Display
quote! {
&::veil::private::RedactionFormatter {
this: ::veil::private::RedactionTarget::Display(#field_accessor),
flags: ::veil::private::RedactFlags { #field_flags },
&veil::private::RedactionFormatter {
this: veil::private::RedactionTarget::Display(#field_accessor),
flags: veil::private::RedactFlags { #field_flags },
specialization: #specialization
}
}
} else {
// std::fmt::Debug
quote! {
&::veil::private::RedactionFormatter {
this: ::veil::private::RedactionTarget::Debug { this: #field_accessor, alternate },
flags: ::veil::private::RedactFlags { #field_flags },
&veil::private::RedactionFormatter {
this: veil::private::RedactionTarget::Debug { this: #field_accessor, alternate },
flags: veil::private::RedactFlags { #field_flags },
specialization: #specialization
}
}
Expand Down
10 changes: 5 additions & 5 deletions veil-macros/src/redactable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,19 @@ fn try_derive(mut item: syn::DeriveInput) -> Result<TokenStream, syn::Error> {
let name_ident = &item.ident;
let (impl_generics, ty_generics, where_clause) = item.generics.split_for_impl();
Ok(quote! {
impl #impl_generics ::veil::Redactable for #name_ident #ty_generics #where_clause {
impl #impl_generics veil::Redactable for #name_ident #ty_generics #where_clause {
fn redact(&self) -> String {
::veil::private::derived_redactable(
veil::private::derived_redactable(
self,
::veil::private::RedactFlags { #flags }
veil::private::RedactFlags { #flags }
)
}

fn redact_into(&self, buffer: &mut dyn ::std::fmt::Write) -> ::std::fmt::Result {
buffer.write_str(
::veil::private::derived_redactable(
veil::private::derived_redactable(
self,
::veil::private::RedactFlags { #flags }
veil::private::RedactFlags { #flags }
)
.as_str()
)
Expand Down

0 comments on commit 4d98e0e

Please sign in to comment.