Skip to content

Commit 04eb681

Browse files
Implement indexed_vec::Idx for ast::NodeId
1 parent b1d03fd commit 04eb681

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/libsyntax/ast.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ use abi::Abi;
2323
use ext::hygiene::SyntaxContext;
2424
use print::pprust;
2525
use ptr::P;
26+
use rustc_data_structures::indexed_vec;
2627
use symbol::{Symbol, keywords};
2728
use tokenstream::{ThinTokenStream, TokenStream};
2829

@@ -269,6 +270,16 @@ impl serialize::UseSpecializedDecodable for NodeId {
269270
}
270271
}
271272

273+
impl indexed_vec::Idx for NodeId {
274+
fn new(idx: usize) -> Self {
275+
NodeId::new(idx)
276+
}
277+
278+
fn index(self) -> usize {
279+
self.as_usize()
280+
}
281+
}
282+
272283
/// Node id used to represent the root of the crate.
273284
pub const CRATE_NODE_ID: NodeId = NodeId(0);
274285

0 commit comments

Comments
 (0)