-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Validate and unpack function arguments tersely #14513
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
Validate and unpack function arguments tersely #14513
Conversation
Add a `take_function_args` helper that provides convenient unpacking of function arguments along with validation that the provided argument count matches the expected. A few functions are updated to leverage the new pattern to demonstrate its usefulness.
alamb
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love it -- thank you @findepi
BTW I bet others would love a chance to clean up the code using this function if we filed a ticket for them to do so.
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
this exports only the newly added take_function_args function. all other utils members are pub(crate)
Co-authored-by: Matthijs Brobbel <m1brobbel@gmail.com>
Co-authored-by: Oleks V <comphead@users.noreply.github.com>
comphead
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm thanks @findepi
And we already have a taker: #14516 (comment) |
Add a
take_function_argshelper that provides convenient unpacking of function arguments along with validation that the provided argument count matches the expected. A few functions are updated to leverage the new pattern to demonstrate its usefulness.