Prettify macro arguments
MODIFY
src/manual/core.rs
src/manual/core.rs
@@ -14,7 +14,7 @@ pub use vec::*;
pub use vector::*;
macro_rules! valid_types {
- ($trait: ident, $($rust_type: ty),+) => {
+ ($trait: ident: $($rust_type: ty),+) => {
/// This sealed trait is implemented for types that are valid to use in corresponding context
pub trait $trait: ::num_traits::NumAssign + PartialOrd + Default + Copy + private::Sealed {}
@@ -30,7 +30,7 @@ macro_rules! valid_types {
}
macro_rules! opencv_type_simple_generic {
- ($type: ident, $trait: ident) => {
+ ($type: ident<$trait: ident>) => {
impl<T: $trait> $crate::traits::OpenCVType<'_> for $type<T> {
type Owned = Self;
type Arg = Self;

MODIFY
src/manual/core/affine3.rs
src/manual/core/affine3.rs
@@ -13,4 +13,4 @@ impl<T: ValidMatxType> Default for Affine3<T> {
}
}
-opencv_type_simple_generic! { Affine3, ValidMatxType }
+opencv_type_simple_generic! { Affine3<ValidMatxType> }

MODIFY
src/manual/core/matx.rs
src/manual/core/matx.rs
@@ -24,7 +24,7 @@ fn index_check(idx: (usize, usize), rows: usize, cols: usize) -> Result<()> {
}
}
-valid_types!(ValidMatxType, f32, f64);
+valid_types!(ValidMatxType: f32, f64);
pub trait MatxTrait: Sized {
type ElemType: ValidMatxType;

MODIFY
src/manual/core/point.rs
src/manual/core/point.rs
@@ -4,7 +4,7 @@ use num_traits::{NumCast, ToPrimitive};
use crate::core::{Rect_, Size_, ValidRectType, ValidSizeType, ValidVecType, Vec2};
-valid_types!(ValidPointType, i32, i64, f32, f64);
+valid_types!(ValidPointType: i32, i64, f32, f64);
#[repr(C)]
#[derive(Copy, Clone, Debug, Default, PartialEq, PartialOrd)]
@@ -76,7 +76,7 @@ impl<T: ValidPointType> Point_<T> {
}
}
-opencv_type_simple_generic! { Point_, ValidPointType }
+opencv_type_simple_generic! { Point_<ValidPointType> }
impl<T> Add for Point_<T>
where

MODIFY
src/manual/core/point3.rs
src/manual/core/point3.rs
@@ -4,7 +4,7 @@ use num_traits::{NumCast, ToPrimitive, Zero};
use crate::core::{Point_, ValidPointType, ValidVecType, Vec3};
-valid_types!(ValidPoint3Type, i32, f32, f64);
+valid_types!(ValidPoint3Type: i32, f32, f64);
#[repr(C)]
#[derive(Copy, Clone, Debug, Default, PartialEq, PartialOrd)]
@@ -74,7 +74,7 @@ impl<T: ValidPoint3Type> Point3_<T> {
Vec3::from([self.x, self.y, self.z])
}
}
-opencv_type_simple_generic! { Point3_, ValidPoint3Type }
+opencv_type_simple_generic! { Point3_<ValidPoint3Type> }
impl<T> Add for Point3_<T>
where

MODIFY
src/manual/core/rect.rs
src/manual/core/rect.rs
@@ -8,7 +8,7 @@ use num_traits::{NumCast, ToPrimitive};
use crate::core::{Point_, prelude::*, RotatedRect, Size_, ValidPointType, ValidSizeType};
-valid_types!(ValidRectType, i32, f32, f64);
+valid_types!(ValidRectType: i32, f32, f64);
#[inline(always)]
fn partial_min<T: PartialOrd>(a: T, b: T) -> T {
@@ -84,7 +84,7 @@ impl<T: ValidRectType> Rect_<T> {
}
}
-opencv_type_simple_generic! { Rect_, ValidRectType }
+opencv_type_simple_generic! { Rect_<ValidRectType> }
impl<P, R> Add<Point_<P>> for Rect_<R>
where

MODIFY
src/manual/core/size.rs
src/manual/core/size.rs
@@ -4,7 +4,7 @@ use num_traits::{NumCast, ToPrimitive};
use crate::core::{Point_, ValidPointType};
-valid_types!(ValidSizeType, i32, i64, f32, f64);
+valid_types!(ValidSizeType: i32, i64, f32, f64);
#[repr(C)]
#[derive(Copy, Clone, Debug, Default, PartialEq, PartialOrd)]
@@ -41,7 +41,7 @@ impl<T: ValidSizeType> Size_<T> {
}
}
-opencv_type_simple_generic! { Size_, ValidSizeType }
+opencv_type_simple_generic! { Size_<ValidSizeType> }
impl<T> Add for Size_<T>
where

MODIFY
src/manual/core/vec.rs
src/manual/core/vec.rs
@@ -11,11 +11,11 @@ pub use self::{scalar::ValidScalarType, vec::ValidVecType};
// additional modules needed because valid_types! introduces module named "private"
mod vec {
- valid_types!(ValidVecType, i8, u8, i16, u16, i32, f32, f64);
+ valid_types!(ValidVecType: i8, u8, i16, u16, i32, f32, f64);
}
mod scalar {
- valid_types!(ValidScalarType, i32, f64);
+ valid_types!(ValidScalarType: i32, f64);
}
macro_rules! vec_impl {
@@ -51,7 +51,7 @@ macro_rules! vec_impl {
}
}
- opencv_type_simple_generic! { $type, $type_trait }
+ opencv_type_simple_generic! { $type<$type_trait> }
};
}

Prettify macro arguments