Skip to content

Commit bcaef15

Browse files
committed
refactor(core): address the clippy::while_let_on_iterator lint
These loops in `const fn` can now be written as `for` loops.
1 parent e649986 commit bcaef15

File tree

1 file changed

+12
-24
lines changed

1 file changed

+12
-24
lines changed

src/r3_core/src/bind/sorter.rs

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -613,33 +613,22 @@ where
613613

614614
// Calculate `TopologicalSortVertexInfo::num_predecessors`
615615
let mut num_vertices_remaining = 0;
616-
{
617-
let mut it_vertices = graph.vertices();
618-
while let Some(v) = it_vertices.next() {
619-
temp_vertex_info[&v] = TopologicalSortVertexInfo {
620-
num_predecessors: 0,
621-
};
622-
num_vertices_remaining += 1;
623-
}
616+
for v in graph.vertices() {
617+
temp_vertex_info[&v] = TopologicalSortVertexInfo {
618+
num_predecessors: 0,
619+
};
620+
num_vertices_remaining += 1;
624621
}
625-
{
626-
let mut it_vertices = graph.vertices();
627-
while let Some(v) = it_vertices.next() {
628-
let mut it_successors = graph.successors(&v);
629-
while let Some(successor) = it_successors.next() {
630-
temp_vertex_info[&successor].num_predecessors += 1;
631-
}
622+
for v in graph.vertices() {
623+
for successor in graph.successors(&v) {
624+
temp_vertex_info[&successor].num_predecessors += 1;
632625
}
633626
}
634627

635628
// Push predecessor-less vertices to `temp_ready_vertex_queue`
636-
{
637-
let mut it_vertices = graph.vertices();
638-
while let Some(v) = it_vertices.next() {
639-
if temp_vertex_info[&v].num_predecessors == 0 {
640-
temp_ready_vertex_queue
641-
.heap_push(v, ReadyVertexQueueBinaryHeapCtx { vertex_ord_lt });
642-
}
629+
for v in graph.vertices() {
630+
if temp_vertex_info[&v].num_predecessors == 0 {
631+
temp_ready_vertex_queue.heap_push(v, ReadyVertexQueueBinaryHeapCtx { vertex_ord_lt });
643632
}
644633
}
645634

@@ -648,8 +637,7 @@ where
648637
{
649638
// Remove `v` from the graph, and push the now-predecessor-less
650639
// vertices to `temp_ready_vertex_queue`
651-
let mut it_successors = graph.successors(&v);
652-
while let Some(successor) = it_successors.next() {
640+
for successor in graph.successors(&v) {
653641
temp_vertex_info[&successor].num_predecessors -= 1;
654642
if temp_vertex_info[&successor].num_predecessors == 0 {
655643
temp_ready_vertex_queue

0 commit comments

Comments
 (0)