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

Flat argument list instead of nested tuples for closures in Validation methods #1

Open
haraldmaida opened this issue Aug 31, 2019 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@haraldmaida
Copy link
Member

Currently the closures in the methods Validation::and_then and Validation::map` get passed nested tuples which can become really ugly with more and more arguments.

We should find a way to flatten the values collected so far by the Validation type, so that the closures either get a list of arguments passed or one flat tuple with all the values.

This will be a breaking change in the API, but I think the advantage outweighs any pain with changing existing implementations.

@haraldmaida haraldmaida added the enhancement New feature or request label Aug 31, 2019
@haraldmaida haraldmaida self-assigned this Aug 31, 2019
@justforcomment
Copy link

Hello from the future..!)

Several times ago i encruntered with the same problem/question, when was trying implement some similar.

Perhaps you have found a solution? There is hardly a universal solution since each possible tuple structure/size requires a separate implementation.

@haraldmaida
Copy link
Member Author

I've got this idea from looking at crates like warp and axum. When I last looked at these, they used a macro to implement some kind of "flatting" trait for tuples of two, three, four and so on up to a number of elements (e.g. 32 elements) in a tuple. So yes it requires a separate implementation for each supported typle size. The solution assumes that for most applications there is no need for more than a certain number of arguments in a tuple.

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

No branches or pull requests

2 participants