From 559127b4517229115397404f20167bc7b702d3d6 Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Tue, 14 Mar 2017 15:50:04 +0100 Subject: [PATCH] Implement indexed_vec::Idx for ast::NodeId --- src/libsyntax/ast.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 4347046b6b80..3dd4bdbd14dd 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -23,6 +23,7 @@ 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 @@ fn default_decode(d: &mut D) -> Result { } } +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);