@@ -54,8 +54,51 @@ impl AsRef<RectangleInt> for Rectangle {
54
54
}
55
55
56
56
impl From < RectangleInt > for Rectangle {
57
- fn from ( r : RectangleInt ) -> Rectangle {
57
+ fn from ( r : RectangleInt ) -> Self {
58
58
skip_assert_initialized ! ( ) ;
59
59
unsafe { * ( & r as * const _ as * const _ ) }
60
60
}
61
61
}
62
+
63
+ impl From < Rectangle > for RectangleInt {
64
+ fn from ( r : Rectangle ) -> Self {
65
+ skip_assert_initialized ! ( ) ;
66
+ unsafe { * ( & r as * const _ as * const _ ) }
67
+ }
68
+ }
69
+
70
+ impl From < cairo:: Rectangle > for Rectangle {
71
+ // rustdoc-stripper-ignore-next
72
+ /// Note that converting between a [`cairo::Rectangle`] and [`Rectangle`]
73
+ /// will probably lead to precisison errors. Use cautiously.
74
+ fn from ( r : cairo:: Rectangle ) -> Self {
75
+ skip_assert_initialized ! ( ) ;
76
+ Self :: new ( r. x as i32 , r. y as i32 , r. width as i32 , r. height as i32 )
77
+ }
78
+ }
79
+
80
+ impl From < Rectangle > for cairo:: Rectangle {
81
+ fn from ( r : Rectangle ) -> Self {
82
+ skip_assert_initialized ! ( ) ;
83
+ Self {
84
+ x : r. x ( ) as f64 ,
85
+ y : r. y ( ) as f64 ,
86
+ width : r. width ( ) as f64 ,
87
+ height : r. height ( ) as f64 ,
88
+ }
89
+ }
90
+ }
91
+
92
+ impl From < pango:: Rectangle > for Rectangle {
93
+ fn from ( r : pango:: Rectangle ) -> Self {
94
+ skip_assert_initialized ! ( ) ;
95
+ Self :: new ( r. x ( ) , r. y ( ) , r. width ( ) , r. height ( ) )
96
+ }
97
+ }
98
+
99
+ impl From < Rectangle > for pango:: Rectangle {
100
+ fn from ( r : Rectangle ) -> Self {
101
+ skip_assert_initialized ! ( ) ;
102
+ Self :: new ( r. x ( ) , r. y ( ) , r. width ( ) , r. height ( ) )
103
+ }
104
+ }
0 commit comments