Make DepNodeIndex use newtype_index macro

This commit is contained in:
Santiago Pastorino 2017-11-04 13:41:53 -03:00
parent a6885cb853
commit 912a3a5752

View file

@ -45,25 +45,10 @@ pub struct DepGraph {
}
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
pub struct DepNodeIndex {
index: u32,
}
impl Idx for DepNodeIndex {
fn new(idx: usize) -> Self {
debug_assert!((idx & 0xFFFF_FFFF) == idx);
DepNodeIndex { index: idx as u32 }
}
fn index(self) -> usize {
self.index as usize
}
}
newtype_index!(DepNodeIndex);
impl DepNodeIndex {
const INVALID: DepNodeIndex = DepNodeIndex {
index: ::std::u32::MAX,
};
const INVALID: DepNodeIndex = DepNodeIndex(::std::u32::MAX);
}
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]