Skip to content

Commit 47282a8

Browse files
: selection: routing: promote terminals true and false (not just true)
Summary: it never came up before due to there being no surface syntax for `False` but terminal promotion should by symmetry be the same for `False` as exists for `True`. Differential Revision: D78169907
1 parent d5e1d88 commit 47282a8

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

ndslice/src/selection.rs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -878,26 +878,28 @@ impl Selection {
878878
}
879879
}
880880

881-
// "Pads out" a selection so that if `Selection::True` appears before
882-
// the final dimension, it becomes All(All(...(True))), enough to fill
883-
// the remaining dimensions.
884-
pub(crate) fn promote_terminal_true(self, dim: usize, max_dim: usize) -> Selection {
881+
/// Pads out a terminal selection (e.g., `True`, `False`) with
882+
/// `All(...)` to reach `max_dim` dimensions.
883+
pub(crate) fn promote_terminal(self, dim: usize, max_dim: usize) -> Selection {
885884
use crate::selection::dsl::*;
886885

887886
match self {
888887
Selection::True if dim < max_dim => all(true_()),
889-
Selection::All(inner) => all(inner.promote_terminal_true(dim + 1, max_dim)),
890-
Selection::Range(r, inner) => range(r, inner.promote_terminal_true(dim + 1, max_dim)),
888+
Selection::False if dim < max_dim => all(false_()),
889+
890+
Selection::All(inner) => all(inner.promote_terminal(dim + 1, max_dim)),
891+
Selection::Range(r, inner) => range(r, inner.promote_terminal(dim + 1, max_dim)),
891892
Selection::Intersection(a, b) => intersection(
892-
a.promote_terminal_true(dim, max_dim),
893-
b.promote_terminal_true(dim, max_dim),
893+
a.promote_terminal(dim, max_dim),
894+
b.promote_terminal(dim, max_dim),
894895
),
895896
Selection::Union(a, b) => union(
896-
a.promote_terminal_true(dim, max_dim),
897-
b.promote_terminal_true(dim, max_dim),
897+
a.promote_terminal(dim, max_dim),
898+
b.promote_terminal(dim, max_dim),
898899
),
899-
Selection::First(inner) => first(inner.promote_terminal_true(dim + 1, max_dim)),
900-
Selection::Any(inner) => any(inner.promote_terminal_true(dim + 1, max_dim)),
900+
Selection::First(inner) => first(inner.promote_terminal(dim + 1, max_dim)),
901+
Selection::Any(inner) => any(inner.promote_terminal(dim + 1, max_dim)),
902+
901903
other => other,
902904
}
903905
}

ndslice/src/selection/routing.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ impl RoutingFrame {
389389
let selection = self
390390
.selection
391391
.clone()
392-
.promote_terminal_true(self.dim, self.slice.num_dim());
392+
.promote_terminal(self.dim, self.slice.num_dim());
393393
match &selection {
394394
Selection::True => ControlFlow::Continue(()),
395395
Selection::False => ControlFlow::Continue(()),
@@ -1624,7 +1624,7 @@ mod tests {
16241624
assert!(step.deliver_here());
16251625
assert_eq!(step.slice.location(&step.here).unwrap(), 42);
16261626

1627-
let selection = all(false_());
1627+
let selection = false_();
16281628
let frame = RoutingFrame::root(selection, slice);
16291629

16301630
let mut steps = vec![];

0 commit comments

Comments
 (0)