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

Better support for Into #5

Closed
BrynCooke opened this issue Mar 30, 2022 · 1 comment · Fixed by #25
Closed

Better support for Into #5

BrynCooke opened this issue Mar 30, 2022 · 1 comment · Fixed by #25

Comments

@BrynCooke
Copy link
Owner

Currently if a collection has elements that are E: Into<Something> then the first time that the field is set the builder will fix the type of E.

This could be improved by making the transient collection of type <Something> and performing the into conversion when the parameter is set.

The downside is that more fancy generic manipulation will need to be done.

@BrynCooke
Copy link
Owner Author

Another idea. All single entries to collections that are not a generic or numeric type is automatically given the Into treatment.
This fixes Strings and also gives the user the opportunity to define their own intermediate type.
For instance, if trying to construct a HeaderName you want to accept &str, String or HeaderName.
Define an enum:

enum IntoHeaderName {
  String(String),
  Str(&str),
  HeaderName(HeaderName)
}

Then From can be implemented for IntoHeaderName for HeaderName and dealt with in the constructor.

@BrynCooke BrynCooke linked a pull request May 1, 2022 that will close this issue
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 a pull request may close this issue.

1 participant