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

Implement rename helper attribute #12

Merged
merged 1 commit into from
Jul 14, 2022

Conversation

yuk1ty
Copy link
Contributor

@yuk1ty yuk1ty commented Jul 8, 2022

Thank you for the lovely crate! I implemented "rename" attribute like #[serde(rename)] because I encountered the case I would like to separate field names and environment variable names.

Overview

For instance, if we set an environment variable as ENV_VARIABLE_A, need to prepare the following Rust struct:

#[derive(LoadEnv)]
struct Example {
    env_variable_a: String,
}

Suppose we'd like to name the field as a. In this case, we can leverage the rename attribute:

#[derive(LoadEnv)]
struct Example {
    #[econf(rename = "env_variable_a")]
    a: String, // we can rename field's name as we like
}

Copy link
Owner

@YushiOMOTE YushiOMOTE left a comment

Choose a reason for hiding this comment

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

Thank you for the nice feature!

@YushiOMOTE YushiOMOTE merged commit 97215b1 into YushiOMOTE:master Jul 14, 2022
@YushiOMOTE YushiOMOTE added the enhancement New feature or request label Jul 14, 2022
@yuk1ty yuk1ty deleted the feature/add-renaming branch July 15, 2022 08:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants