[Question] BoxedRefMut to BoxedRef possible?
Currently updating our code to use the new BoxedRef semantics and came across the following:
I have a BoxedRefMut and want to pass along to a function expecting a (non-mutable) BoxedRef and can't figure out how to make it work. Is this possible?
Thanks!
Ah, I think I missed that transform, let me see if this can be added. But otherwise, generally, is it a requirement that your function takes BoxedRef? Maybe you can take something like &impl MatTraitConst? Then you can pass Mat, BoxedRef<Mat> and BoxedRefMut<Mat>.
Maybe you can take something like &impl MatTraitConst?
For sure! We tried this first after reading through some other comment threads but ran into issue when trying to pass the MatTraitConst object to cv::highgui::imshow... we get the error
the trait bound `impl MatTraitConst: opencv::core::ToInputArray` is not satisfied
the trait `opencv::core::ToInputArray` is not implemented for `impl MatTraitConst`
What about having impl MatTraitConst + ToInputArray then on your argument? Or if you're using the argument only in imshow you can just have impl ToInputArray.
Yes, that can work, it just seemed a bit awkward and then I started second guessing my approach. If this is the suggested way, then we can make it work.
...as I think about it some more, the impl trait approach probably saves us some into's when sending non-boxed Mats, etc.
Thank you so much for the crate and your quick response. (as an aside, we actually found a potential issue in our code that the borrow checker can now see with the new BoxedRefs 👍)
Feel free to close this as you feel fit.
I still think that conversion from BoxedRefMut to BoxedRef might be useful for some use cases so I'll close this issue when I push those changes. Thank you for you kind words!
The necessary impl From is now added in 0.92.3
Thank you much!