Skip to content
This repository has been archived by the owner on Jun 8, 2021. It is now read-only.

RFC: MatrixTrait::try_invert() #116

Closed
federicomenaquintero opened this issue Mar 16, 2017 · 2 comments
Closed

RFC: MatrixTrait::try_invert() #116

federicomenaquintero opened this issue Mar 16, 2017 · 2 comments

Comments

@federicomenaquintero
Copy link
Contributor

I appreciate how MatrixTrait::invert() actually ensures that the matrix is invertible, and panics otherwise; it has caught a lot of bugs in librsvg.

Now, I need to know if a matrix is actually invertible, to validate user-supplied data (actually, transformations that come from an SVG file).

The quick-and-dirty way is to call ffi::cairo_matrix_invert() by hand and test the result.

A more idiomatic way could be to have this in MatrixTrait:

pub trait MatrixTrait {
    ...
     fn try_invert(&self) -> Result <Matrix, Status>;
    ...
}

What do you think? I can submit a pull request for this if you like the API.

@GuillaumeGomez
Copy link
Member

Seems reasonable and a good idea.

federicomenaquintero added a commit to federicomenaquintero/cairo that referenced this issue Mar 16, 2017
See gtk-rs#116 - we return a
Result<Matrix, Status> with the result of cairo_matrix_invert().
federicomenaquintero added a commit to federicomenaquintero/cairo that referenced this issue Mar 16, 2017
See gtk-rs#116 - we return a
Result<Matrix, Status> with the result of cairo_matrix_invert().
federicomenaquintero added a commit to federicomenaquintero/cairo that referenced this issue Jul 6, 2017
See gtk-rs#116 - we return a
Result<Matrix, Status> with the result of cairo_matrix_invert().
@federicomenaquintero
Copy link
Contributor Author

This has been merged; closing.

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

No branches or pull requests

2 participants