pub trait ModifyInplace {
// Required method
unsafe fn modify_inplace<Res>(
&mut self,
f: impl FnOnce(&Self, &mut Self) -> Res,
) -> Res;
}
Required Methods§
Sourceunsafe fn modify_inplace<Res>(
&mut self,
f: impl FnOnce(&Self, &mut Self) -> Res,
) -> Res
unsafe fn modify_inplace<Res>( &mut self, f: impl FnOnce(&Self, &mut Self) -> Res, ) -> Res
Helper function to call OpenCV functions that allow in-place modification of a Mat
or another similar object. By passing
a mutable reference to the Mat
to this function your closure will get called with the read reference and a write references
to the same Mat
. This is unsafe in a general case as it leads to having non-exclusive mutable access to the internal data,
but it can be useful for some performance sensitive operations. One example of an OpenCV function that allows such in-place
modification is imgproc::threshold
.
§Safety
Caller must make sure that any functions called inside the closure can act on a Mat
in-place.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.