cv-rs icon indicating copy to clipboard operation
cv-rs copied to clipboard

Accept closures in highgui_set_mouse_callback

Open vadixidav opened this issue 6 years ago • 3 comments

In highgui_set_mouse_callback currently it is not possible to pass it a closure. By storing an arbitrary dyn Fn type in the Box inside its definition, it should be possible to accept an arbitrary closure to ease callback handling.

vadixidav avatar Mar 08 '19 03:03 vadixidav

Making <F: FnMut> would be enough.

Pzixel avatar Mar 12 '19 10:03 Pzixel

@Pzixel That is true, but we then have to turn it into a dyn FnMut so that we can pass it to C as a single pointer type since the type is erased. We will find out if we can use FnMut based on if any data races can occur in the code. I think there is a good chance we can accept FnMut. We can only do that if the C code never creates a data race. If it does then we will need to use Fn. If C makes a cross thread data race then we will also need to force it to be Send and Sync.

vadixidav avatar Mar 12 '19 13:03 vadixidav

I actually already fixed this in #117. Once that is merged we can close this.

vadixidav avatar Apr 06 '19 01:04 vadixidav