diff options
| author | bors <bors@rust-lang.org> | 2024-04-16 06:41:11 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-04-16 06:41:11 +0000 |
| commit | 88d1a1c6fdf6e607606876cdab672eebdf6a3c71 (patch) | |
| tree | 438ae4e11b312666a2c073fff0184ec42aa7274f /compiler/rustc_data_structures/src/graph/vec_graph | |
| parent | 2f08c2c96501990caab0e47a095d76ffd6a31f16 (diff) | |
| parent | 3d3a584e4d88a572d68d7996122cda69a38dcf2e (diff) | |
| download | rust-88d1a1c6fdf6e607606876cdab672eebdf6a3c71.tar.gz rust-88d1a1c6fdf6e607606876cdab672eebdf6a3c71.zip | |
Auto merge of #3469 - rust-lang:rustup-2024-04-16, r=RalfJung
Automatic Rustup
Diffstat (limited to 'compiler/rustc_data_structures/src/graph/vec_graph')
| -rw-r--r-- | compiler/rustc_data_structures/src/graph/vec_graph/mod.rs | 16 | ||||
| -rw-r--r-- | compiler/rustc_data_structures/src/graph/vec_graph/tests.rs | 4 |
2 files changed, 7 insertions, 13 deletions
diff --git a/compiler/rustc_data_structures/src/graph/vec_graph/mod.rs b/compiler/rustc_data_structures/src/graph/vec_graph/mod.rs index 00f6266ce1d..26c86469fad 100644 --- a/compiler/rustc_data_structures/src/graph/vec_graph/mod.rs +++ b/compiler/rustc_data_structures/src/graph/vec_graph/mod.rs @@ -1,4 +1,4 @@ -use crate::graph::{DirectedGraph, GraphSuccessors, WithNumEdges, WithNumNodes, WithSuccessors}; +use crate::graph::{DirectedGraph, NumEdges, Successors}; use rustc_index::{Idx, IndexVec}; #[cfg(test)] @@ -80,28 +80,20 @@ impl<N: Idx + Ord> VecGraph<N> { impl<N: Idx> DirectedGraph for VecGraph<N> { type Node = N; -} -impl<N: Idx> WithNumNodes for VecGraph<N> { fn num_nodes(&self) -> usize { self.node_starts.len() - 1 } } -impl<N: Idx> WithNumEdges for VecGraph<N> { +impl<N: Idx> NumEdges for VecGraph<N> { fn num_edges(&self) -> usize { self.edge_targets.len() } } -impl<'graph, N: Idx> GraphSuccessors<'graph> for VecGraph<N> { - type Item = N; - - type Iter = std::iter::Cloned<std::slice::Iter<'graph, N>>; -} - -impl<N: Idx + Ord> WithSuccessors for VecGraph<N> { - fn successors(&self, node: N) -> <Self as GraphSuccessors<'_>>::Iter { +impl<N: Idx + Ord> Successors for VecGraph<N> { + fn successors(&self, node: N) -> impl Iterator<Item = Self::Node> { self.successors(node).iter().cloned() } } diff --git a/compiler/rustc_data_structures/src/graph/vec_graph/tests.rs b/compiler/rustc_data_structures/src/graph/vec_graph/tests.rs index 7c866da6009..87c8d25f094 100644 --- a/compiler/rustc_data_structures/src/graph/vec_graph/tests.rs +++ b/compiler/rustc_data_structures/src/graph/vec_graph/tests.rs @@ -1,3 +1,5 @@ +use crate::graph; + use super::*; fn create_graph() -> VecGraph<usize> { @@ -37,6 +39,6 @@ fn successors() { #[test] fn dfs() { let graph = create_graph(); - let dfs: Vec<_> = graph.depth_first_search(0).collect(); + let dfs: Vec<_> = graph::depth_first_search(&graph, 0).collect(); assert_eq!(dfs, vec![0, 1, 3, 4, 2]); } |
