Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow user input environmental variables as base path #21

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

stevefan1999-personal
Copy link

No description provided.

@stevefan1999-personal stevefan1999-personal marked this pull request as ready for review September 25, 2023 05:41
t.elems.last().unwrap().into_token_stream(),
);
let (lit, base) = (
syn::parse::<LitStr>(lit.into())?,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why parse again instead of just checking if let Expr::Let(litlit) = lit and let Lit::Str(litstr) = &litlit.lit?

@@ -67,20 +67,42 @@ pub fn deflate_utf8_file(ts: TokenStream) -> TokenStream {
}

fn inner(ts: TokenStream, utf8: bool) -> Result<impl Into<TokenStream>> {
if let Ok(t) = syn::parse::<ExprTuple>(ts.clone()) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about actually using a custom Parse implementation

@@ -67,20 +67,42 @@ pub fn deflate_utf8_file(ts: TokenStream) -> TokenStream {
}

fn inner(ts: TokenStream, utf8: bool) -> Result<impl Into<TokenStream>> {
if let Ok(t) = syn::parse::<ExprTuple>(ts.clone()) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why tuple? The invocation will then become deflate_file!(("file.gz", "base")) with double parentheses.

syn::parse::<LitStr>(lit.into())?,
syn::parse::<LitStr>(base.into())?,
);
let key = quote!(#base).to_string();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just get base.value()?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants