Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Implement indexed_vec::Idx for ast::NodeId
  • Loading branch information
michaelwoerister committed Mar 22, 2017
1 parent 9e0589a commit 559127b
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/libsyntax/ast.rs
Expand Up @@ -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};

Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 559127b

Please sign in to comment.