-
Notifications
You must be signed in to change notification settings - Fork 128
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
Trait for Entry handler function types? #438
Comments
As a workaround you could also implement your own trait responsible for setting the value: trait HandlerFuncType: Sized {
fn set(self, entry: &mut Entry<Self>) -> &mut EntryOptions;
}
The
My gut tells me that this will be backwards-compatible, but we'll have to see what the semver-checks CI job says. I agree that this would be an improvement. Feel free to open a pr. |
Works perfectly, thank you! |
I wanted to write a helper that generalized the function to set for an entry, like:
but
Entry.set_handler_fn
is explicitly implemented for each HandlerFunc type separately, so I don't think I can provide an adequate type bound onF
.Instead of implementing
Entry.set_handler_fn
explicitly for each HandlerFunc type, why not provide a trait for all HandlerFunc types? e.g.And then do
Would this work? I think this is backwards-compatible, so I don't see any downsides to making this change. I'm fairly new to Rust, so let me know if I'm missing anything.
The text was updated successfully, but these errors were encountered: