Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature wanted] can i use validate_type macro in my project #316

Closed
honwhy opened this issue Jan 10, 2022 · 3 comments
Closed

[feature wanted] can i use validate_type macro in my project #316

honwhy opened this issue Jan 10, 2022 · 3 comments

Comments

@honwhy
Copy link

honwhy commented Jan 10, 2022

can i use validate_type macro in my project
valid_types!(ValidRectType: u32);

@twistedfall
Copy link
Owner

Well, theoretically there shouldn't be anything preventing you from using any type with Rect_ I just wanted to be on the safe side. Can you still please tell me why you need it?

@honwhy
Copy link
Author

honwhy commented Jan 14, 2022

as we use coordinate x and y, (0,0) starts from left-top, maybe it is more precisely using usize type.
I am doing some kind of exercise, code
follow the example, which using photon-rs to do image crop,

impl SpecTransform<&Crop> for Photon {
    fn transform(&mut self, op: &Crop) {
        let img = transform::crop(&mut self.0, op.x1, op.y1, op.x2, op.y2);
        self.0 = img;
    }
}

while I try to implement crop with opencv-rs, I have to type casting

impl SpecTransform<&Crop> for Opencv {
    fn transform(&mut self, op: &Crop) {
        let rect = Rect_::from_points(
            Point_::<i32>::new(op.x1 as i32, op.y1 as i32),
            Point_::<i32>::new(op.x2 as i32, op.y2 as i32),
        );
        let dest = Mat::roi(&self.0, rect).unwrap();
        self.0 = dest;
    }
}

@twistedfall
Copy link
Owner

It should be fixed on 0.63.0, Rect_, Point_, Size_, Point3_, VecN no longer impose restrictions on its container types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants