-
Notifications
You must be signed in to change notification settings - Fork 79
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
MidiInput::connect user data is not necessary #25
Comments
I thought about removing it, but there is a difference compared to closure captures, which make it still useful: I agree that for most cases, closure captures are probably sufficient ... so maybe the normal methods should not have the additional Anyway, passing |
I don't really have a problem with passing Do you have a specific use case in mind that would make use of the user data? :) Btw, even as it is now, it doesn't have to be |
Yeah, probably there is no usecase that couldn't also be solved with a channel (sender/receiver). But I'd like to have some more feedback from others ... Concerning the |
Note to self: Actually there is already a branch (which I forgot about) where the |
I like userdata because the connection takes ownership of it exactly while it is connected, so you can do this and
[edit] Although if |
@vklquevs Would it be useful if In general I think that I won't remove the userdata. |
It would certainly be nice for symmetry, although at the moment I'm just giving it an mpsc::channel so it's not critical. I did have a look at how much work it would be to do that, but there are a lot of ways the connection can fail! |
@vklquevs: Can you have a look at #44 and evaluate whether that would be useful to you so that you wouldn't need the user data anymore? I'm still trying to find the best solution here. With #44 you would have two options to pass data into the closure:
|
Yes, if I've read it correctly then that would still work well. Even if I'm wrong (it's sadly been a while since I last looked at my project), it does look like removing user data is the way to go, so please do what you feel works best and I can work with it. |
FnMut, no? It can take ownership and be called multiple times (e.g. |
The user data passed to
MidiInput::connect()
is not necessary because anything that the closure wants to reference can be captured.(It's only necessary in the underlying C lib because it doesn't have closures.)
So
user_data
can be entirely removed fromHandlerData
, right?(I always pass
()
for user data inMidiInput::connect()
anyway, and capture what I need.)The text was updated successfully, but these errors were encountered: