Skip to content

Commit 559127b

Browse files
Implement indexed_vec::Idx for ast::NodeId
1 parent 9e0589a commit 559127b

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/libsyntax/ast.rs

+11
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

@@ -275,6 +276,16 @@ impl serialize::UseSpecializedDecodable for NodeId {
275276
}
276277
}
277278

279+
impl indexed_vec::Idx for NodeId {
280+
fn new(idx: usize) -> Self {
281+
NodeId::new(idx)
282+
}
283+
284+
fn index(self) -> usize {
285+
self.as_usize()
286+
}
287+
}
288+
278289
/// Node id used to represent the root of the crate.
279290
pub const CRATE_NODE_ID: NodeId = NodeId(0);
280291

0 commit comments

Comments
 (0)