@@ -11,34 +11,34 @@ unrepresentable**.
11
11
# use std :: fmt :: Write ;
12
12
#[derive(Default )]
13
13
struct Serializer { output : String }
14
- struct SerializeStruct { ser : Serializer }
14
+ struct SerializeStruct { serializer : Serializer }
15
15
16
16
impl Serializer {
17
17
fn serialize_struct (mut self , name : & str ) -> SerializeStruct {
18
18
let _ = writeln! (& mut self . output, " {name} {{" );
19
- SerializeStruct { ser : self }
19
+ SerializeStruct { serializer : self }
20
20
}
21
21
}
22
22
23
23
impl SerializeStruct {
24
24
fn serialize_field (mut self , key : & str , value : & str ) -> Self {
25
- let _ = writeln! (& mut self . ser . output, " {key}={value};" );
25
+ let _ = writeln! (& mut self . serializer . output, " {key}={value};" );
26
26
self
27
27
}
28
28
29
29
fn finish_struct (mut self ) -> Serializer {
30
- self . ser . output. push_str (" }\ n" );
31
- self . ser
30
+ self . serializer . output. push_str (" }\ n" );
31
+ self . serializer
32
32
}
33
33
}
34
34
35
35
fn main () {
36
- let ser = Serializer :: default ()
36
+ let serializer = Serializer :: default ()
37
37
. serialize_struct (" User" )
38
38
. serialize_field (" id" , " 42" )
39
39
. serialize_field (" name" , " Alice" )
40
40
. finish_struct ();
41
- println! (" {}" , ser . output);
41
+ println! (" {}" , serializer . output);
42
42
}
43
43
```
44
44
0 commit comments