@@ -4,11 +4,11 @@ use crate::sys;
44use std:: convert:: { AsMut , AsRef , TryFrom , TryInto } ;
55use std:: hash:: { Hash , Hasher } ;
66use std:: mem;
7+ use std:: num:: TryFromIntError ;
78use std:: ops:: {
89 Add , AddAssign , BitAnd , BitOr , Deref , DerefMut , Div , DivAssign , Mul , MulAssign , Neg , Sub ,
910 SubAssign ,
1011} ;
11- use std:: num:: TryFromIntError ;
1212use std:: ptr;
1313
1414/// The maximal integer value that can be used for rectangles.
@@ -709,17 +709,22 @@ impl From<(i32, i32, u32, u32)> for Rect {
709709///
710710/// assert_eq!(rect1, rect2);
711711/// ```
712- impl < T > TryFrom < [ T ; 4 ] > for Rect where
713- T : TryInto < u32 > + TryInto < i32 > ,
714- // need to do this to support Infallible conversions
715- TryFromIntError : From < <T as TryInto < i32 > >:: Error > ,
716- TryFromIntError : From < <T as TryInto < u32 > >:: Error > ,
712+ impl < T > TryFrom < [ T ; 4 ] > for Rect
713+ where
714+ T : TryInto < u32 > + TryInto < i32 > ,
715+ // need to do this to support Infallible conversions
716+ TryFromIntError : From < <T as TryInto < i32 > >:: Error > ,
717+ TryFromIntError : From < <T as TryInto < u32 > >:: Error > ,
717718{
718- type Error = TryFromIntError ;
719- fn try_from ( [ x, y, width, height] : [ T ; 4 ] ) -> Result < Self , TryFromIntError > {
720- Ok ( Rect :: new ( x. try_into ( ) ?, y. try_into ( ) ?,
721- width. try_into ( ) ?, height. try_into ( ) ?) )
722- }
719+ type Error = TryFromIntError ;
720+ fn try_from ( [ x, y, width, height] : [ T ; 4 ] ) -> Result < Self , TryFromIntError > {
721+ Ok ( Rect :: new (
722+ x. try_into ( ) ?,
723+ y. try_into ( ) ?,
724+ width. try_into ( ) ?,
725+ height. try_into ( ) ?,
726+ ) )
727+ }
723728}
724729
725730impl AsRef < sys:: SDL_Rect > for Rect {
0 commit comments