File tree Expand file tree Collapse file tree 1 file changed +14
-10
lines changed Expand file tree Collapse file tree 1 file changed +14
-10
lines changed Original file line number Diff line number Diff line change @@ -279,7 +279,7 @@ impl<T: CoordNum> AffineTransform<T> {
279
279
}
280
280
}
281
281
282
- impl < T : CoordNum + Neg < Output = T > > AffineTransform < T > {
282
+ impl < T : CoordNum + Neg > AffineTransform < T > {
283
283
/// Return the inverse of a given transform. Composing a transform with its inverse yields
284
284
/// the [identity matrix](Self::identity)
285
285
#[ must_use]
@@ -300,16 +300,20 @@ impl<T: CoordNum + Neg<Output = T>> AffineTransform<T> {
300
300
if determinant == T :: zero ( ) {
301
301
return None ; // The matrix is not invertible
302
302
}
303
-
304
303
let inv_det = T :: one ( ) / determinant;
305
- Some ( Self :: new (
306
- e * inv_det,
307
- -b * inv_det,
308
- ( b * yoff - e * xoff) * inv_det,
309
- -d * inv_det,
310
- a * inv_det,
311
- ( d * xoff - a * yoff) * inv_det,
312
- ) )
304
+
305
+ // If conversion of either the b or d matrix value fails, bail out
306
+ match ( T :: from ( -b * inv_det) , T :: from ( -d * inv_det) ) {
307
+ ( Some ( inv_b) , Some ( inv_d) ) => Some ( Self :: new (
308
+ e * inv_det,
309
+ inv_b,
310
+ ( b * yoff - e * xoff) * inv_det,
311
+ inv_d,
312
+ a * inv_det,
313
+ ( d * xoff - a * yoff) * inv_det,
314
+ ) ) ,
315
+ _ => None ,
316
+ }
313
317
}
314
318
}
315
319
You can’t perform that action at this time.
0 commit comments