add manual Vec
MODIFY
src/hub/manual/core.rs
src/hub/manual/core.rs
@@ -3,6 +3,7 @@ pub use self::point::*;
pub use self::rect::*;
pub use self::scalar::*;
pub use self::size::*;
+pub use self::vec::*;
macro_rules! valid_types {
($trait: ident, $($rust_type: ty),+) => {
@@ -20,3 +21,4 @@ mod point;
mod rect;
mod scalar;
mod size;
+mod vec;

ADD
src/hub/manual/core/vec.rs
+use std::ops::{Deref, DerefMut};
+
+valid_types!(ValidVecType, u8, i16, u16, i32, f32, f64);
+
+macro_rules! vec_impl {
+ ($type: ident, $count: expr) => {
+ #[repr(C)]
+ #[derive(Copy, Clone, Debug, PartialEq)]
+ pub struct $type<T: ValidVecType>(pub [T; $count]);
+
+ impl<T: ValidVecType> From<[T; $count]> for $type<T> {
+ fn from(s: [T; $count]) -> $type<T> {
+ $type::<T>(s)
+ }
+ }
+
+ impl<T: ValidVecType> Deref for $type<T> {
+ type Target = [T; $count];
+
+ fn deref(&self) -> &Self::Target {
+ &self.0
+ }
+ }
+
+ impl<T: ValidVecType> DerefMut for $type<T> {
+ fn deref_mut(&mut self) -> &mut Self::Target {
+ &mut self.0
+ }
+ }
+
+ impl<T: ValidVecType + Default + Copy> Default for $type<T> {
+ fn default() -> Self {
+ Self([Default::default(); $count])
+ }
+ }
+ };
+}
+
+vec_impl!(Vec2, 2);
+vec_impl!(Vec3, 3);
+vec_impl!(Vec4, 4);
+vec_impl!(Vec6, 6);
+vec_impl!(Vec8, 8);

ADD
tests/vec.rs
+use opencv::core;
+
+#[test]
+fn vec() {
+ let mut a = core::Vec3b::default();
+ assert_eq!(a[0], 0);
+ assert_eq!(a.len(), 3);
+
+ a[1] = 2;
+ assert_eq!(a[1], 2);
+}

add manual Vec