@@ -22,66 +22,6 @@ pub struct FontDesc<'a> {
22
22
style : FontStyle ,
23
23
}
24
24
25
- impl < ' a > From < & ' a str > for FontDesc < ' a > {
26
- fn from ( from : & ' a str ) -> FontDesc < ' a > {
27
- FontDesc :: new ( from. into ( ) , 12.0 , FontStyle :: Normal )
28
- }
29
- }
30
-
31
- impl < ' a > From < FontFamily < ' a > > for FontDesc < ' a > {
32
- fn from ( family : FontFamily < ' a > ) -> FontDesc < ' a > {
33
- FontDesc :: new ( family, 12.0 , FontStyle :: Normal )
34
- }
35
- }
36
-
37
- impl < ' a , T : Into < f64 > > From < ( FontFamily < ' a > , T ) > for FontDesc < ' a > {
38
- fn from ( ( family, size) : ( FontFamily < ' a > , T ) ) -> FontDesc < ' a > {
39
- FontDesc :: new ( family, size. into ( ) , FontStyle :: Normal )
40
- }
41
- }
42
-
43
- impl From < f64 > for FontDesc < ' static > {
44
- fn from ( size : f64 ) -> FontDesc < ' static > {
45
- FontDesc :: new ( FontFamily :: SansSerif , size. into ( ) , FontStyle :: Normal )
46
- }
47
- }
48
-
49
- impl From < u32 > for FontDesc < ' static > {
50
- fn from ( size : u32 ) -> FontDesc < ' static > {
51
- FontDesc :: new ( FontFamily :: SansSerif , size. into ( ) , FontStyle :: Normal )
52
- }
53
- }
54
-
55
- impl < ' a , T : Into < f64 > > From < ( & ' a str , T ) > for FontDesc < ' a > {
56
- fn from ( ( typeface, size) : ( & ' a str , T ) ) -> FontDesc < ' a > {
57
- FontDesc :: new ( typeface. into ( ) , size. into ( ) , FontStyle :: Normal )
58
- }
59
- }
60
-
61
- impl < ' a , T : Into < f64 > , S : Into < FontStyle > > From < ( FontFamily < ' a > , T , S ) > for FontDesc < ' a > {
62
- fn from ( ( family, size, style) : ( FontFamily < ' a > , T , S ) ) -> FontDesc < ' a > {
63
- FontDesc :: new ( family, size. into ( ) , style. into ( ) )
64
- }
65
- }
66
-
67
- impl < ' a , T : Into < f64 > , S : Into < FontStyle > > From < ( & ' a str , T , S ) > for FontDesc < ' a > {
68
- fn from ( ( typeface, size, style) : ( & ' a str , T , S ) ) -> FontDesc < ' a > {
69
- FontDesc :: new ( typeface. into ( ) , size. into ( ) , style. into ( ) )
70
- }
71
- }
72
-
73
- /// The trait that allows some type turns into a font description
74
- pub trait IntoFont < ' a > {
75
- /// Make the font description from the source type
76
- fn into_font ( self ) -> FontDesc < ' a > ;
77
- }
78
-
79
- impl < ' a , T : Into < FontDesc < ' a > > > IntoFont < ' a > for T {
80
- fn into_font ( self ) -> FontDesc < ' a > {
81
- self . into ( )
82
- }
83
- }
84
-
85
25
impl < ' a > FontDesc < ' a > {
86
26
/// Create a new font
87
27
///
@@ -207,3 +147,51 @@ impl<'a> FontDesc<'a> {
207
147
}
208
148
}
209
149
}
150
+
151
+ impl < ' a > From < & ' a str > for FontDesc < ' a > {
152
+ fn from ( from : & ' a str ) -> FontDesc < ' a > {
153
+ FontDesc :: new ( from. into ( ) , 12.0 , FontStyle :: Normal )
154
+ }
155
+ }
156
+
157
+ impl < ' a > From < FontFamily < ' a > > for FontDesc < ' a > {
158
+ fn from ( family : FontFamily < ' a > ) -> FontDesc < ' a > {
159
+ FontDesc :: new ( family, 12.0 , FontStyle :: Normal )
160
+ }
161
+ }
162
+
163
+ impl < ' a , T : Into < f64 > > From < ( FontFamily < ' a > , T ) > for FontDesc < ' a > {
164
+ fn from ( ( family, size) : ( FontFamily < ' a > , T ) ) -> FontDesc < ' a > {
165
+ FontDesc :: new ( family, size. into ( ) , FontStyle :: Normal )
166
+ }
167
+ }
168
+
169
+ impl < ' a , T : Into < f64 > > From < ( & ' a str , T ) > for FontDesc < ' a > {
170
+ fn from ( ( typeface, size) : ( & ' a str , T ) ) -> FontDesc < ' a > {
171
+ FontDesc :: new ( typeface. into ( ) , size. into ( ) , FontStyle :: Normal )
172
+ }
173
+ }
174
+
175
+ impl < ' a , T : Into < f64 > , S : Into < FontStyle > > From < ( FontFamily < ' a > , T , S ) > for FontDesc < ' a > {
176
+ fn from ( ( family, size, style) : ( FontFamily < ' a > , T , S ) ) -> FontDesc < ' a > {
177
+ FontDesc :: new ( family, size. into ( ) , style. into ( ) )
178
+ }
179
+ }
180
+
181
+ impl < ' a , T : Into < f64 > , S : Into < FontStyle > > From < ( & ' a str , T , S ) > for FontDesc < ' a > {
182
+ fn from ( ( typeface, size, style) : ( & ' a str , T , S ) ) -> FontDesc < ' a > {
183
+ FontDesc :: new ( typeface. into ( ) , size. into ( ) , style. into ( ) )
184
+ }
185
+ }
186
+
187
+ /// The trait that allows some type turns into a font description
188
+ pub trait IntoFont < ' a > {
189
+ /// Make the font description from the source type
190
+ fn into_font ( self ) -> FontDesc < ' a > ;
191
+ }
192
+
193
+ impl < ' a , T : Into < FontDesc < ' a > > > IntoFont < ' a > for T {
194
+ fn into_font ( self ) -> FontDesc < ' a > {
195
+ self . into ( )
196
+ }
197
+ }
0 commit comments