Skip to content

Commit 3fe24ab

Browse files
authored
refactor(tree): Abstract the concept of a NodeId (#15237)
### What does this PR try to resolve? This is a follow up to #15233. The primary goal is to make things more type safe / easier to follow through adding semantic information to the types. A secondary benefit is this allows us to track some light weight debug information in NodeIds making debugging Edges a lot easier. We could put this behind a `#[cfg(debug_asserts)]` but I'm assuming this is cheap enough to not be worth doing that to the code. ### How should we test and review this PR? ### Additional information
2 parents 7ea222d + 128604f commit 3fe24ab

File tree

3 files changed

+121
-66
lines changed

3 files changed

+121
-66
lines changed

src/cargo/ops/tree/format/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::fmt;
33
use anyhow::{bail, Error};
44

55
use self::parse::{Parser, RawChunk};
6-
use super::{Graph, Node};
6+
use super::{Graph, Node, NodeId};
77

88
mod parse;
99

@@ -41,7 +41,7 @@ impl Pattern {
4141
Ok(Pattern(chunks))
4242
}
4343

44-
pub fn display<'a>(&'a self, graph: &'a Graph<'a>, node_index: usize) -> Display<'a> {
44+
pub fn display<'a>(&'a self, graph: &'a Graph<'a>, node_index: NodeId) -> Display<'a> {
4545
Display {
4646
pattern: self,
4747
graph,
@@ -53,7 +53,7 @@ impl Pattern {
5353
pub struct Display<'a> {
5454
pattern: &'a Pattern,
5555
graph: &'a Graph<'a>,
56-
node_index: usize,
56+
node_index: NodeId,
5757
}
5858

5959
impl<'a> fmt::Display for Display<'a> {

0 commit comments

Comments
 (0)