1
1
# Serialization in Rustc
2
2
3
3
Rustc has to [ serialize] and deserialize various data during compilation.
4
- Specifially :
4
+ Specifically :
5
5
6
6
- "Crate metadata", mainly query outputs, are serialized in a binary
7
7
format into ` rlib ` and ` rmeta ` files that are output when compiling a library
@@ -17,7 +17,7 @@ Specifially:
17
17
18
18
The [ ` rustc_serialize ` ] crate defines two traits for types which can be serialized:
19
19
20
- ``` rust
20
+ ``` rust,ignore
21
21
pub trait Encodable<S: Encoder> {
22
22
fn encode(&self, s: &mut S) -> Result<(), S::Error>;
23
23
}
@@ -35,7 +35,7 @@ usually implemented by [derives]. These generate implementations that forward
35
35
deserialization to the fields of the struct or enum. For a struct those impls
36
36
look something like this:
37
37
38
- ``` rust
38
+ ``` rust,ingore
39
39
# #![feature(rustc_private)]
40
40
# extern crate rustc_serialize;
41
41
# use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
@@ -59,7 +59,7 @@ impl<D: Decoder> Decodable<D> for MyStruct {
59
59
let int = d.read_struct_field("int", 0, Decodable::decode)?;
60
60
let float = d.read_struct_field("float", 1, Decodable::decode)?;
61
61
62
- Ok (MyStruct :: new ( int , float , SyntaxContext :: root ()) )
62
+ Ok(MyStruct { int, float } )
63
63
})
64
64
}
65
65
}
0 commit comments