Mark most functions #[inline] to enable cross-crate inlining
MODIFY
binding-generator/src/writer/rust_native/tpl/class/impl_clone.tpl.rs
binding-generator/src/writer/rust_native/tpl/class/impl_clone.tpl.rs
impl Clone for {{rust_local}} {
- #[inline(always)]
+ #[inline]
/// Calls try_clone() and panics if that fails
fn clone(&self) -> Self {
self.try_clone().expect("Cannot clone {{rust_local}}")

MODIFY
binding-generator/src/writer/rust_native/tpl/func/rust.tpl.rs
binding-generator/src/writer/rust_native/tpl/func/rust.tpl.rs
-{{attributes}}
{{doc_comment}}
{{debug}}
+#[inline]
+{{attributes}}
{{visibility}}{{unsafety_decl}}fn {{name}}{{generic_decl}}({{decl_args}}) -> {{rv_rust_full}} {
{{pre_call_args}}
{{prefix}}{{unsafety_call}}{ sys::{{identifier}}({{call_args}}) }.into_result(){{ret_map}}{{suffix}}

MODIFY
src/manual/core.rs
src/manual/core.rs
@@ -43,13 +43,13 @@ mod sized;
mod vec;
mod vector;
-#[inline(always)]
+#[inline]
pub const fn CV_MAT_DEPTH(flags: i32) -> i32 {
#![allow(non_snake_case)]
flags & crate::core::Mat_DEPTH_MASK
}
-#[inline(always)]
+#[inline]
pub const fn CV_MAKETYPE(depth: i32, cn: i32) -> i32 {
#![allow(non_snake_case)]
CV_MAT_DEPTH(depth) + ((cn - 1) << crate::core::CV_CN_SHIFT)

MODIFY
src/manual/core/mat.rs
src/manual/core/mat.rs
@@ -43,13 +43,13 @@ pub trait DataType: Copy + private::Sealed {
macro_rules! data_type {
($rust_type: ty, $mat_depth: expr, $channels: expr) => {
impl $crate::core::DataType for $rust_type {
- #[inline(always)]
+ #[inline]
fn depth() -> i32 { $mat_depth }
- #[inline(always)]
+ #[inline]
fn channels() -> i32 { $channels }
- #[inline(always)]
+ #[inline]
fn typ() -> i32 { $crate::core::CV_MAKETYPE($mat_depth, $channels) }
}
@@ -128,6 +128,7 @@ unsafe fn convert_ptr_mut<T>(r: &mut u8) -> &mut T {
&mut *(r as *mut u8 as *mut T)
}
+#[inline]
fn match_format<T: DataType>(mat_type: i32) -> Result<()> {
let out_type = T::typ();
if mat_type == out_type {
@@ -141,6 +142,7 @@ fn match_format<T: DataType>(mat_type: i32) -> Result<()> {
}
}
+#[inline]
fn match_dims(mat: &(impl MatTraitConst + ?Sized), dims: usize) -> Result<()> {
let mat_dims = mat.dims() as usize;
if mat_dims == dims {
@@ -163,6 +165,7 @@ fn match_indices(mat: &(impl MatTraitConst + ?Sized), idx: &[i32]) -> Result<()>
}
}
+#[inline]
fn match_total(mat: &(impl MatTraitConst + ?Sized), idx: i32) -> Result<()> {
let size = mat.total()?;
if 0 <= idx && (idx as usize) < size {
@@ -172,6 +175,7 @@ fn match_total(mat: &(impl MatTraitConst + ?Sized), idx: i32) -> Result<()> {
}
}
+#[inline]
fn match_is_continuous(mat: &(impl MatTraitConst + ?Sized)) -> Result<()> {
if mat.is_continuous()? {
Ok(())
@@ -239,7 +243,7 @@ impl Mat {
pub(crate) mod mat_forward {
use super::*;
- #[inline(always)]
+ #[inline]
pub fn at<T: DataType>(mat: &(impl MatTraitConst + ?Sized), i0: i32) -> Result<&T> {
match_format::<T>(mat.typ()?)
.and_then(|_| match_dims(mat, 2))
@@ -247,7 +251,7 @@ pub(crate) mod mat_forward {
.and_then(|_| unsafe { mat.at_unchecked(i0) })
}
- #[inline(always)]
+ #[inline]
pub fn at_mut<T: DataType>(mat: &mut (impl MatTrait + ?Sized), i0: i32) -> Result<&mut T> {
match_format::<T>(mat.typ()?)
.and_then(|_| match_dims(mat, 2))
@@ -255,52 +259,52 @@ pub(crate) mod mat_forward {
unsafe { mat.at_unchecked_mut(i0) }
}
- #[inline(always)]
+ #[inline]
pub fn at_2d<T: DataType>(mat: &(impl MatTraitConst + ?Sized), row: i32, col: i32) -> Result<&T> {
match_format::<T>(mat.typ()?)
.and_then(|_| match_indices(mat, &[row, col]))
.and_then(|_| unsafe { mat.at_2d_unchecked(row, col) })
}
- #[inline(always)]
+ #[inline]
pub fn at_2d_mut<T: DataType>(mat: &mut (impl MatTrait + ?Sized), row: i32, col: i32) -> Result<&mut T> {
match_format::<T>(mat.typ()?)
.and_then(|_| match_indices(mat, &[row, col]))?;
unsafe { mat.at_2d_unchecked_mut(row, col) }
}
- #[inline(always)]
+ #[inline]
pub fn at_pt<T: DataType>(mat: &(impl MatTraitConst + ?Sized), pt: Point) -> Result<&T> {
at_2d(mat, pt.y, pt.x)
}
- #[inline(always)]
+ #[inline]
pub fn at_pt_mut<T: DataType>(mat: &mut (impl MatTrait + ?Sized), pt: Point) -> Result<&mut T> {
at_2d_mut(mat, pt.y, pt.x)
}
- #[inline(always)]
+ #[inline]
pub fn at_3d<T: DataType>(mat: &(impl MatTraitConst + ?Sized), i0: i32, i1: i32, i2: i32) -> Result<&T> {
match_format::<T>(mat.typ()?)
.and_then(|_| match_indices(mat, &[i0, i1, i2]))
.and_then(|_| unsafe { mat.at_3d_unchecked(i0, i1, i2) })
}
- #[inline(always)]
+ #[inline]
pub fn at_3d_mut<T: DataType>(mat: &mut (impl MatTrait + ?Sized), i0: i32, i1: i32, i2: i32) -> Result<&mut T> {
match_format::<T>(mat.typ()?)
.and_then(|_| match_indices(mat, &[i0, i1, i2]))?;
unsafe { mat.at_3d_unchecked_mut(i0, i1, i2) }
}
- #[inline(always)]
+ #[inline]
pub fn at_nd<'s, T: core::DataType>(mat: &'s (impl MatTraitConst + ?Sized), idx: &[i32]) -> Result<&'s T> {
match_format::<T>(mat.typ()?)
.and_then(|_| match_indices(mat, idx))
.and_then(|_| unsafe { mat.at_nd_unchecked(idx) })
}
- #[inline(always)]
+ #[inline]
pub fn at_nd_mut<'s, T: core::DataType>(mat: &'s mut (impl MatTrait + ?Sized), idx: &[i32]) -> Result<&'s mut T> {
match_format::<T>(mat.typ()?)
.and_then(|_| match_indices(mat, idx))?;
@@ -313,6 +317,7 @@ pub trait MatTraitConstManual: MatTraitConst {
///
/// # Safety
/// Caller must ensure that index is within Mat bounds
+ #[inline]
unsafe fn at_unchecked<T: DataType>(&self, i0: i32) -> Result<&T> {
let mat_size = self.size()?;
let (i, j) = if self.is_continuous()? || mat_size.width == 1 {
@@ -330,6 +335,7 @@ pub trait MatTraitConstManual: MatTraitConst {
/// Like `Mat::at_2d()` but performs no bounds or type checks
/// # Safety
/// Caller must ensure that indices are within Mat bounds
+ #[inline]
unsafe fn at_2d_unchecked<T: DataType>(&self, row: i32, col: i32) -> Result<&T> {
self.ptr_2d(row, col)
.map(|ptr| convert_ptr(ptr))
@@ -338,6 +344,7 @@ pub trait MatTraitConstManual: MatTraitConst {
/// Like `Mat::at_pt()` but performs no bounds or type checks
/// # Safety
/// Caller must ensure that point is within Mat bounds
+ #[inline]
unsafe fn at_pt_unchecked<T: DataType>(&self, pt: Point) -> Result<&T> {
self.at_2d_unchecked(pt.y, pt.x)
}
@@ -345,6 +352,7 @@ pub trait MatTraitConstManual: MatTraitConst {
/// Like `Mat::at_3d()` but performs no bounds or type checks
/// # Safety
/// Caller must ensure that indices are within Mat bounds
+ #[inline]
unsafe fn at_3d_unchecked<T: DataType>(&self, i0: i32, i1: i32, i2: i32) -> Result<&T> {
self.ptr_3d(i0, i1, i2)
.map(|ptr| convert_ptr(ptr))
@@ -353,12 +361,14 @@ pub trait MatTraitConstManual: MatTraitConst {
/// Like `Mat::at_nd()` but performs no bounds or type checks
/// # Safety
/// Caller must ensure that indices are within Mat bounds
+ #[inline]
unsafe fn at_nd_unchecked<T: core::DataType>(&self, idx: &[i32]) -> Result<&T> {
self.ptr_nd(idx)
.map(|ptr| convert_ptr(ptr))
}
/// Return a complete read-only row
+ #[inline]
fn at_row<T: DataType>(&self, row: i32) -> Result<&[T]> {
match_format::<T>(self.typ()?)
.and_then(|_| match_indices(self, &[row, 0]))
@@ -368,29 +378,34 @@ pub trait MatTraitConstManual: MatTraitConst {
/// Like `Mat::at_row()` but performs no bounds or type checks
/// # Safety
/// Caller must ensure that index is within Mat bounds
+ #[inline]
unsafe fn at_row_unchecked<T: DataType>(&self, row: i32) -> Result<&[T]> {
let width = self.size()?.width as usize;
self.ptr(row)
.map(|x| slice::from_raw_parts(convert_ptr(x), width))
}
+ #[inline]
fn size(&self) -> Result<core::Size> {
extern "C" { fn cv_manual_Mat_size(instance: *const c_void) -> sys::Result<core::Size>; }
unsafe { cv_manual_Mat_size(self.as_raw_Mat()) }
.into_result()
}
+ #[inline]
fn is_allocated(&self) -> bool {
!self.data().is_null()
}
/// Raw pointer to the underlying data array, can be NULL
+ #[inline]
fn data(&self) -> *const u8 {
extern "C" { fn cv_manual_Mat_data(instance: *const c_void) -> *const u8; }
unsafe { cv_manual_Mat_data(self.as_raw_Mat()) }
}
/// Returns underlying data array as byte slice, Mat must be continuous.
+ #[inline]
fn data_bytes(&self) -> Result<&[u8]> {
match_is_continuous(self)
.and_then(|_| {
@@ -403,6 +418,7 @@ pub trait MatTraitConstManual: MatTraitConst {
})
}
+ #[inline]
fn data_typed<T: DataType>(&self) -> Result<&[T]> {
match_format::<T>(self.typ()?)
.and_then(|_| match_is_continuous(self))
@@ -411,6 +427,7 @@ pub trait MatTraitConstManual: MatTraitConst {
/// # Safety
/// Caller must ensure that the `T` type argument corresponds to the data stored in the `Mat`
+ #[inline]
unsafe fn data_typed_unchecked<T: DataType>(&self) -> Result<&[T]> {
let data = self.data();
if data.is_null() {
@@ -457,6 +474,7 @@ pub trait MatTraitManual: MatTraitConstManual + MatTrait {
/// Like `Mat::at_mut()` but performs no bounds or type checks
/// # Safety
/// Caller must ensure that index is within Mat bounds
+ #[inline]
unsafe fn at_unchecked_mut<T: DataType>(&mut self, i0: i32) -> Result<&mut T> {
let (i, j) = idx_to_row_col(self, i0)?;
self.ptr_2d_mut(i, j)
@@ -466,6 +484,7 @@ pub trait MatTraitManual: MatTraitConstManual + MatTrait {
/// Like `Mat::at_2d_mut()` but performs no bounds or type checks
/// # Safety
/// Caller must ensure that indices are within Mat bounds
+ #[inline]
unsafe fn at_2d_unchecked_mut<T: DataType>(&mut self, row: i32, col: i32) -> Result<&mut T> {
self.ptr_2d_mut(row, col)
.map(|ptr| convert_ptr_mut(ptr))
@@ -474,6 +493,7 @@ pub trait MatTraitManual: MatTraitConstManual + MatTrait {
/// Like `Mat::at_pt_mut()` but performs no bounds or type checks
/// # Safety
/// Caller must ensure that point is within Mat bounds
+ #[inline]
unsafe fn at_pt_unchecked_mut<T: DataType>(&mut self, pt: Point) -> Result<&mut T> {
self.at_2d_unchecked_mut(pt.y, pt.x)
}
@@ -481,6 +501,7 @@ pub trait MatTraitManual: MatTraitConstManual + MatTrait {
/// Like `Mat::at_3d_mut()` but performs no bounds or type checks
/// # Safety
/// Caller must ensure that indices are within Mat bounds
+ #[inline]
unsafe fn at_3d_unchecked_mut<T: DataType>(&mut self, i0: i32, i1: i32, i2: i32) -> Result<&mut T> {
self.ptr_3d_mut(i0, i1, i2)
.map(|ptr| convert_ptr_mut(ptr))
@@ -489,12 +510,14 @@ pub trait MatTraitManual: MatTraitConstManual + MatTrait {
/// Like `Mat::at_nd_mut()` but performs no bounds or type checks
/// # Safety
/// Caller must ensure that indices are within Mat bounds
+ #[inline]
unsafe fn at_nd_unchecked_mut<T: core::DataType>(&mut self, idx: &[i32]) -> Result<&mut T> {
self.ptr_nd_mut(idx)
.map(|ptr| convert_ptr_mut(ptr))
}
/// Return a complete writeable row
+ #[inline]
fn at_row_mut<T: DataType>(&mut self, row: i32) -> Result<&mut [T]> {
match_format::<T>(self.typ()?)
.and_then(|_| match_indices(self, &[row, 0]))?;
@@ -504,6 +527,7 @@ pub trait MatTraitManual: MatTraitConstManual + MatTrait {
/// Like `Mat::at_row_mut()` but performs no bounds or type checks
/// # Safety
/// Caller must ensure that index is within Mat bounds
+ #[inline]
unsafe fn at_row_unchecked_mut<T: DataType>(&mut self, row: i32) -> Result<&mut [T]> {
let width = self.size()?.width as usize;
self.ptr_mut(row)
@@ -514,6 +538,7 @@ pub trait MatTraitManual: MatTraitConstManual + MatTrait {
///
/// ## Parameters
/// * s: Assigned scalar converted to the actual array type.
+ #[inline]
fn set(&mut self, s: Scalar) -> Result<()> {
extern "C" { fn cv_manual_Mat_set(instance: *mut c_void, s: *const Scalar) -> sys::Result_void; }
unsafe { cv_manual_Mat_set(self.as_raw_mut_Mat(), &s) }
@@ -521,6 +546,7 @@ pub trait MatTraitManual: MatTraitConstManual + MatTrait {
}
/// Returns underlying data array as mutable byte slice, Mat must be continuous.
+ #[inline]
fn data_bytes_mut(&mut self) -> Result<&mut [u8]> {
match_is_continuous(self)
.and_then(|_| {
@@ -528,6 +554,7 @@ pub trait MatTraitManual: MatTraitConstManual + MatTrait {
})
}
+ #[inline]
fn data_typed_mut<T: DataType>(&mut self) -> Result<&mut [T]> {
match_format::<T>(self.typ()?)
.and_then(|_| match_is_continuous(self))?;
@@ -536,6 +563,7 @@ pub trait MatTraitManual: MatTraitConstManual + MatTrait {
/// # Safety
/// Caller must ensure that the `T` type argument corresponds to the data stored in the `Mat`
+ #[inline]
unsafe fn data_typed_unchecked_mut<T: DataType>(&mut self) -> Result<&mut [T]> {
let total = self.total()?;
Ok(slice::from_raw_parts_mut(self.data_mut() as *mut u8 as *mut T, total))
@@ -682,6 +710,7 @@ impl<T: MatSizeTraitConst> MatSizeTraitConstManual for T {}
impl Deref for MatSize {
type Target = [i32];
+ #[inline]
fn deref(&self) -> &Self::Target {
let ptr = self.to_ri32() as *const i32;
unsafe { slice::from_raw_parts(ptr, self.dims() as usize) }
@@ -697,6 +726,7 @@ impl fmt::Debug for MatSize {
impl Deref for MatStep {
type Target = [size_t];
+ #[inline]
fn deref(&self) -> &Self::Target {
extern "C" { fn cv_manual_MatStep_deref(instance: *const c_void) -> *const size_t; }
let ptr = unsafe { cv_manual_MatStep_deref(self.as_raw_MatStep()) };
@@ -723,6 +753,7 @@ pub trait MatConstIteratorTraitManual: MatConstIteratorTrait {
unsafe { cv_manual_MatConstIterator_has_elements(self.as_raw_MatConstIterator()) }
}
+ #[inline]
fn current<T: DataType>(&self) -> Result<&T> {
match_format::<T>(self.typ())?;
if self.has_elements() {

MODIFY
src/manual/core/mat/mat_.rs
src/manual/core/mat/mat_.rs
@@ -27,7 +27,7 @@ pub struct Mat_<T> {
impl<T: DataType> TryFrom<Mat> for Mat_<T> {
type Error = Error;
- #[inline(always)]
+ #[inline]
fn try_from(mat: Mat) -> Result<Self, Self::Error> {
match_format::<T>(mat.typ()?)
.map(|_| Self { inner: mat, _type: PhantomData })
@@ -64,25 +64,27 @@ impl<T: DataType> Mat_<T> {
self.as_raw_mut_Mat()
}
- #[inline(always)]
+ #[inline]
pub fn at(&self, i0: i32) -> Result<&T> {
match_dims(self, 2)
.and_then(|_| match_total(self, i0))
.and_then(|_| unsafe { self.at_unchecked(i0) })
}
- #[inline(always)]
+ #[inline]
pub fn at_mut(&mut self, i0: i32) -> Result<&mut T> {
match_dims(self, 2)
.and_then(|_| match_total(self, i0))?;
unsafe { self.at_unchecked_mut(i0) }
}
+ #[inline]
pub fn data_typed(&self) -> Result<&[T]> {
match_is_continuous(self)
.and_then(|_| unsafe { self.data_typed_unchecked() })
}
+ #[inline]
pub fn data_typed_mut(&mut self) -> Result<&mut [T]> {
match_is_continuous(self)?;
unsafe { self.data_typed_unchecked_mut() }
@@ -122,6 +124,7 @@ impl<T> Boxed for Mat_<T> {
}
impl<T> ToInputArray for Mat_<T> {
+ #[inline]
fn input_array(&self) -> Result<_InputArray> {
self.inner.input_array()
}

MODIFY
src/manual/core/ptr/ptr_extern.rs
src/manual/core/ptr/ptr_extern.rs
@@ -24,17 +24,17 @@ macro_rules! ptr_extern {
}
impl $crate::manual::core::PtrExtern for $crate::manual::core::Ptr<$type> {
- #[inline(always)]
+ #[inline]
unsafe fn extern_delete(&mut self) {
$extern_delete(self.as_raw_mut())
}
- #[inline(always)]
+ #[inline]
unsafe fn extern_inner_as_ptr(&self) -> *const std::ffi::c_void {
$extern_inner_as_ptr(self.as_raw())
}
- #[inline(always)]
+ #[inline]
unsafe fn extern_inner_as_ptr_mut(&mut self) -> *mut std::ffi::c_void {
$extern_inner_as_ptr_mut(self.as_raw_mut())
}
@@ -48,7 +48,7 @@ macro_rules! ptr_extern_ctor {
extern "C" { fn $extern_new(val: <<$type as $crate::traits::OpenCVType>::ExternContainer as $crate::traits::OpenCVTypeExternContainer>::ExternSendMut) -> *mut std::ffi::c_void; }
impl $crate::manual::core::PtrExternCtor<$type> for $crate::manual::core::Ptr<$type> {
- #[inline(always)]
+ #[inline]
unsafe fn extern_new(val: <<$type as $crate::traits::OpenCVType>::ExternContainer as $crate::traits::OpenCVTypeExternContainer>::ExternSendMut) -> *mut std::ffi::c_void {
$extern_new(val)
}

MODIFY
src/manual/core/vector/vector_extern.rs
src/manual/core/vector/vector_extern.rs
@@ -73,77 +73,77 @@ macro_rules! vector_extern {
}
impl $crate::manual::core::VectorExtern<$type> for $crate::manual::core::Vector<$type> {
- #[inline(always)]
+ #[inline]
unsafe fn extern_new() -> $vector_extern_mut {
$extern_new()
}
- #[inline(always)]
+ #[inline]
unsafe fn extern_delete(&mut self) {
$extern_delete(self.as_raw_mut())
}
- #[inline(always)]
+ #[inline]
unsafe fn extern_len(&self) -> $crate::platform_types::size_t {
$extern_len(self.as_raw())
}
- #[inline(always)]
+ #[inline]
unsafe fn extern_is_empty(&self) -> bool {
$extern_is_empty(self.as_raw())
}
- #[inline(always)]
+ #[inline]
unsafe fn extern_capacity(&self) -> $crate::platform_types::size_t {
$extern_capacity(self.as_raw())
}
- #[inline(always)]
+ #[inline]
unsafe fn extern_shrink_to_fit(&mut self) {
$extern_shrink_to_fit(self.as_raw_mut())
}
- #[inline(always)]
+ #[inline]
unsafe fn extern_reserve(&mut self, additional: $crate::platform_types::size_t) {
$extern_reserve(self.as_raw_mut(), additional)
}
- #[inline(always)]
+ #[inline]
unsafe fn extern_remove(&mut self, index: $crate::platform_types::size_t) {
$extern_remove(self.as_raw_mut(), index)
}
- #[inline(always)]
+ #[inline]
unsafe fn extern_swap(&mut self, index1: $crate::platform_types::size_t, index2: $crate::platform_types::size_t) {
$extern_swap(self.as_raw_mut(), index1, index2)
}
- #[inline(always)]
+ #[inline]
unsafe fn extern_clear(&mut self) {
$extern_clear(self.as_raw_mut())
}
- #[inline(always)]
+ #[inline]
unsafe fn extern_get(&self, index: $crate::platform_types::size_t) -> $crate::sys::Result<<$type as $crate::traits::OpenCVType<'_>>::ExternReceive> {
$extern_get(self.as_raw(), index)
}
- #[inline(always)]
+ #[inline]
unsafe fn extern_push<'a>(&mut self, val: <<<$type as $crate::traits::OpenCVType<'a>>::Arg as $crate::traits::OpenCVTypeArg<'a>>::ExternContainer as $crate::traits::OpenCVTypeExternContainer>::ExternSend) {
$extern_push(self.as_raw_mut(), val)
}
- #[inline(always)]
+ #[inline]
unsafe fn extern_push_owned(&mut self, val: <<$type as $crate::traits::OpenCVType>::ExternContainer as $crate::traits::OpenCVTypeExternContainer>::ExternSend) {
$extern_push(self.as_raw_mut(), val)
}
- #[inline(always)]
+ #[inline]
unsafe fn extern_insert<'a>(&mut self, index: $crate::platform_types::size_t, val: <<<$type as $crate::traits::OpenCVType<'a>>::Arg as $crate::traits::OpenCVTypeArg<'a>>::ExternContainer as $crate::traits::OpenCVTypeExternContainer>::ExternSend) {
$extern_insert(self.as_raw_mut(), index, val)
}
- #[inline(always)]
+ #[inline]
unsafe fn extern_set<'a>(&mut self, index: $crate::platform_types::size_t, val: <<<$type as $crate::traits::OpenCVType<'a>>::Arg as $crate::traits::OpenCVTypeArg<'a>>::ExternContainer as $crate::traits::OpenCVTypeExternContainer>::ExternSend) {
$extern_set(self.as_raw_mut(), index, val)
}
@@ -168,7 +168,7 @@ macro_rules! vector_copy_non_bool {
$extern_clone: ident $(,)?
) => {
impl $crate::manual::core::Vector<$type> where $crate::manual::core::Vector<$type>: $crate::manual::core::VectorExtern<$type> {
- #[inline(always)]
+ #[inline]
unsafe fn extern_clone(&self) -> $vector_extern_mut {
extern "C" { fn $extern_clone(instance: $vector_extern_const) -> $vector_extern_mut; }
$extern_clone(self.as_raw())
@@ -176,26 +176,27 @@ macro_rules! vector_copy_non_bool {
}
impl $crate::manual::core::VectorElement for $type where $crate::manual::core::Vector<$type>: $crate::manual::core::VectorExtern<$type> {
- #[inline(always)]
+ #[inline]
fn opencv_vector_to_vec(v: &$crate::manual::core::Vector<$type>) -> std::vec::Vec<$type> {
v.as_slice().to_vec()
}
}
impl std::clone::Clone for $crate::manual::core::Vector<$type> where Self: $crate::manual::core::VectorExtern<$type> {
+ #[inline]
fn clone(&self) -> Self {
unsafe { Self::from_raw(self.extern_clone()) }
}
}
impl $crate::manual::core::VectorExternCopyNonBool<$type> for $crate::manual::core::Vector<$type> {
- #[inline(always)]
+ #[inline]
unsafe fn extern_data(&self) -> *const $type {
extern "C" { fn $extern_data_const(instance: $vector_extern_const) -> *const $type; }
$extern_data_const(self.as_raw())
}
- #[inline(always)]
+ #[inline]
unsafe fn extern_data_mut(&mut self) -> *mut $type {
extern "C" { fn $extern_data_mut(instance: $vector_extern_mut) -> *mut $type; }
$extern_data_mut(self.as_raw_mut())
@@ -208,6 +209,7 @@ macro_rules! vector_copy_non_bool {
macro_rules! vector_non_copy_or_bool {
(clone $type: ty) => {
impl std::clone::Clone for $crate::manual::core::Vector<$type> where Self: $crate::manual::core::VectorExtern<$type> {
+ #[inline]
fn clone(&self) -> Self {
let mut out = Self::with_capacity(self.capacity());
self.iter()
@@ -219,7 +221,7 @@ macro_rules! vector_non_copy_or_bool {
};
($type: ty) => {
impl $crate::manual::core::VectorElement for $type where $crate::manual::core::Vector<$type>: $crate::manual::core::VectorExtern<$type> {
- #[inline(always)]
+ #[inline]
fn opencv_vector_to_vec(v: &$crate::manual::core::Vector<$type>) -> std::vec::Vec<$type> {
(0..v.len()).map(|x| unsafe { v.get_unchecked(x) }).collect()
}

Mark most functions #[inline] to enable cross-crate inlining