diff options
| author | Michael Woerister <michaelwoerister@posteo.net> | 2017-03-14 15:50:04 +0100 |
|---|---|---|
| committer | Michael Woerister <michaelwoerister@posteo.net> | 2017-03-22 16:11:18 +0100 |
| commit | 559127b4517229115397404f20167bc7b702d3d6 (patch) | |
| tree | 845d0f6c43070eab19a45be30a3124da833dc56c /src/libsyntax | |
| parent | 9e0589a52b73e254460f90beb010f380b09ff0ba (diff) | |
| download | rust-559127b4517229115397404f20167bc7b702d3d6.tar.gz rust-559127b4517229115397404f20167bc7b702d3d6.zip | |
Implement indexed_vec::Idx for ast::NodeId
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 4347046b6b8..3dd4bdbd14d 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -23,6 +23,7 @@ use abi::Abi; use ext::hygiene::SyntaxContext; use print::pprust; use ptr::P; +use rustc_data_structures::indexed_vec; use symbol::{Symbol, keywords}; use tokenstream::{ThinTokenStream, TokenStream}; @@ -275,6 +276,16 @@ impl serialize::UseSpecializedDecodable for NodeId { } } +impl indexed_vec::Idx for NodeId { + fn new(idx: usize) -> Self { + NodeId::new(idx) + } + + fn index(self) -> usize { + self.as_usize() + } +} + /// Node id used to represent the root of the crate. pub const CRATE_NODE_ID: NodeId = NodeId(0); |
