Skip to content

Conversation

@prestwich
Copy link
Member

No description provided.

@prestwich prestwich force-pushed the prestwich/from-env-macro branch from 8062790 to 210577f Compare April 25, 2025 12:44
@prestwich prestwich force-pushed the prestwich/from-env-macro branch from 210577f to cc31fed Compare April 25, 2025 12:45
@Evalir Evalir self-requested a review April 29, 2025 10:21
Comment on lines +105 to +114
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()
}
Copy link
Member

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 {
Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

done :)

Copy link
Member

@Evalir Evalir left a 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 :)

@prestwich prestwich merged commit df9abb0 into main Apr 30, 2025
5 checks passed
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.

3 participants