-
Notifications
You must be signed in to change notification settings - Fork 0
A normal macro for loading env vars and stuff I guess #11
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
Conversation
8062790
to
210577f
Compare
210577f
to
cc31fed
Compare
pub(crate) fn field_name(&self, idx: usize) -> Ident { | ||
if let Some(field_name) = self.field_name.as_ref() { | ||
return field_name.clone(); | ||
} | ||
|
||
let n = format!("field_{}", idx); | ||
syn::parse_str::<Ident>(&n) | ||
.map_err(|_| syn::Error::new(self.span, "Failed to create field name")) | ||
.unwrap() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, so for tuple structs, we'd get instead of the struct prop name, field_0, field_1...,field_n
and so forth? This seems fine to me to support tuple structs although I'm not sure in which cases you'd want to do a config with a tuple struct.
use init4_from_env_derive::FromEnv; | ||
|
||
#[derive(FromEnv, Debug)] | ||
pub struct FromEnvTest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should probably add a test with a tuple struct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm. this is really nice :)
No description provided.