Say narrow_rel_base, and let a container pass None for it

`narrow` said what the argument did to a value it never named, so a reader
had to go and find out which value. It is `narrow_rel_base`, and the
resolved one stays the bare `rel_base` -- which is also the only one in
`Painter`, `Placing` and `LayoutHolds`, where there is nothing to tell it
apart from.

It takes `impl Into<Option<[Option<Len>; 2]>>`, so a container that does not
narrow anything writes `None` rather than `[None; 2]`, and `Span` builds the
one case that does with a `then` instead of a mutable array.

Cold layout is byte-identical to `84dad21`.
This commit is contained in:
iris-ai committed 2026-09-19 16:55:48 -04:00
1 parent aeb60e50f5
commit beb138632a
8 files changed
+55 -49

No files matched your search

+3 -5
View File
@@ -36,7 +36,7 @@ impl Widget for Span {
None => {
let room = Place::Within(Part::From(along(cursor, far)));
painter
.widget_at(child, [None; 2], axis.pair(room, across))
.widget_at(child, None, axis.pair(room, across))
.len(axis)
}
};
@@ -121,10 +121,8 @@ impl Widget for Span {
// room is put there as it is, and one not made yet is made here.
let slot = along(from, start);
let place = axis.pair(Place::Fill(Part::From(slot)), across);
let mut narrow = [None; 2];
if len.leftover > Weight::ZERO && shares {
narrow[axis as usize] = Some(slot.len());
}
let narrow =
(len.leftover > Weight::ZERO && shares).then(|| axis.pair(Some(slot.len()), None));
let used = painter.place_at(child, narrow, place).len(!axis);
if shrinks {
// Choosing between a fixed and a relative length from the