Make DepNodeIndex use newtype_index macro
This commit is contained in:
parent
a6885cb853
commit
912a3a5752
1 changed files with 2 additions and 17 deletions
|
@ -45,25 +45,10 @@ pub struct DepGraph {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
|
newtype_index!(DepNodeIndex);
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl DepNodeIndex {
|
impl DepNodeIndex {
|
||||||
const INVALID: DepNodeIndex = DepNodeIndex {
|
const INVALID: DepNodeIndex = DepNodeIndex(::std::u32::MAX);
|
||||||
index: ::std::u32::MAX,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
|
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
|
||||||
|
|
Loading…
Reference in a new issue