mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-21 17:52:12 +03:00
Implement indexed_vec::Idx for ast::NodeId
This commit is contained in:
@@ -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: Decoder>(d: &mut D) -> Result<NodeId, D::Error> {
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user