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)]
|
||||
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)]
|
||||
|
|
Loading…
Reference in a new issue