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

[Feature] Support impl Into<FieldTy> for new parameters. #62

Closed
xFrednet opened this issue Sep 16, 2023 · 3 comments
Closed

[Feature] Support impl Into<FieldTy> for new parameters. #62

xFrednet opened this issue Sep 16, 2023 · 3 comments

Comments

@xFrednet
Copy link

I'm working on a project, that requires types to be transformed into an internal representation. Usually, this is done by calling .into() on the type. It would be awesome if the generated macro would support impl Into<FieldTy> parameters.

I imagine something like this:

#[derive(new)]
struct Foo {
    #[new(into)]
	x: u32,
}

which would generate:

impl Foo {
    fn new(x: impl Into<u32>) {
         Foo {
             x: x.into(),
         }
    }
}
@OmarTawfik
Copy link
Contributor

I implemented the feature in #65 (first time contributor to this crate). Please let me know what you think.

@polarathene
Copy link

@nrc this issue can be closed since the #65 PR was merged?

@xFrednet
Copy link
Author

Thank you for the implementation!

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

No branches or pull requests

3 participants