diff options
| author | Eduard Burtescu <edy.burt@gmail.com> | 2016-09-17 23:31:03 +0300 |
|---|---|---|
| committer | Eduard Burtescu <edy.burt@gmail.com> | 2016-09-20 20:08:06 +0300 |
| commit | 221d1a97e505d00fc1664c5b2d9041f8b78aa933 (patch) | |
| tree | 1e2f686fb89b143ca397f208a3f6c1be0a5d086f /src/libsyntax | |
| parent | b01d4891e2935cf24242e44b50dfa37efc28d28c (diff) | |
| download | rust-221d1a97e505d00fc1664c5b2d9041f8b78aa933.tar.gz rust-221d1a97e505d00fc1664c5b2d9041f8b78aa933.zip | |
serialize: allow specifying the default behavior for specializations.
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast.rs | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 70e614f9c9a..c18b36161df 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -300,7 +300,7 @@ pub struct ParenthesizedParameterData { pub output: Option<P<Ty>>, } -#[derive(Clone, Copy, PartialEq, PartialOrd, Eq, Ord, RustcEncodable, Hash, Debug)] +#[derive(Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Hash, Debug)] pub struct NodeId(u32); impl NodeId { @@ -328,7 +328,17 @@ impl fmt::Display for NodeId { } } -impl serialize::UseSpecializedDecodable for NodeId {} +impl serialize::UseSpecializedEncodable for NodeId { + fn default_encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { + s.emit_u32(self.0) + } +} + +impl serialize::UseSpecializedDecodable for NodeId { + fn default_decode<D: Decoder>(d: &mut D) -> Result<NodeId, D::Error> { + d.read_u32().map(NodeId) + } +} /// Node id used to represent the root of the crate. pub const CRATE_NODE_ID: NodeId = NodeId(0); |
