@@ -20,7 +20,8 @@ pub struct SmolStr(Repr);
20
20
21
21
impl SmolStr {
22
22
pub fn new < T > ( text : T ) -> SmolStr
23
- where T : Into < String > + AsRef < str >
23
+ where
24
+ T : Into < String > + AsRef < str > ,
24
25
{
25
26
SmolStr ( Repr :: new ( text) )
26
27
}
@@ -122,7 +123,8 @@ impl fmt::Display for SmolStr {
122
123
}
123
124
124
125
impl < T > From < T > for SmolStr
125
- where T : Into < String > + AsRef < str >
126
+ where
127
+ T : Into < String > + AsRef < str > ,
126
128
{
127
129
fn from ( text : T ) -> Self {
128
130
Self :: new ( text)
@@ -144,7 +146,8 @@ enum Repr {
144
146
145
147
impl Repr {
146
148
fn new < T > ( text : T ) -> Self
147
- where T : Into < String > + AsRef < str >
149
+ where
150
+ T : Into < String > + AsRef < str > ,
148
151
{
149
152
{
150
153
let text = text. as_ref ( ) ;
@@ -173,7 +176,7 @@ impl Repr {
173
176
match self {
174
177
Repr :: Heap ( data) => data. len ( ) ,
175
178
Repr :: Inline { len, .. } => * len as usize ,
176
- Repr :: Substring { newlines, spaces } => * newlines + * spaces
179
+ Repr :: Substring { newlines, spaces } => * newlines + * spaces,
177
180
}
178
181
}
179
182
@@ -204,14 +207,18 @@ mod serde {
204
207
impl serde:: Serialize for SmolStr {
205
208
fn serialize < S > ( & self , serializer : S ) -> Result < S :: Ok , S :: Error >
206
209
where
207
- S : serde:: Serializer
208
- { self . as_str ( ) . serialize ( serializer) }
210
+ S : serde:: Serializer ,
211
+ {
212
+ self . as_str ( ) . serialize ( serializer)
213
+ }
209
214
}
210
215
211
216
impl < ' de > serde:: Deserialize < ' de > for SmolStr {
212
217
fn deserialize < D > ( deserializer : D ) -> Result < Self , D :: Error >
213
218
where
214
- D : serde:: Deserializer < ' de >
215
- { <& ' de str >:: deserialize ( deserializer) . map ( SmolStr :: from) }
219
+ D : serde:: Deserializer < ' de > ,
220
+ {
221
+ <& ' de str >:: deserialize ( deserializer) . map ( SmolStr :: from)
222
+ }
216
223
}
217
224
}
0 commit comments