Ask a value a question through a reference
A method taking `self` can only be called on a value, so anywhere the caller
holds a reference it has to dereference to ask -- which costs the caller
whether or not the type is `Copy` (Bryan, 2026-09-20, correcting the opposite
change made in 7502176).
So every method that answers a question about a value takes `&self`:
`Holds`'s four, `AxisHolds` and `LayoutHolds`'s three each, `LayoutLen`'s
`is_px`, `is_only_leftover`, `declared` and `fills`, and `Size::within_box`.
The two callers passing `LayoutLen::declared` as a function value say the
closure instead.
Builders that return a changed copy, and methods on a handle that is meant to
be given up, still take `self`.
This commit is contained in:
1 parent
750217631d
commit
445287c95c
6 files changed
+17
-17
No files matched your search
@@ -665,7 +665,7 @@ impl Widgets {
|
||||
// the box it was offered.
|
||||
widget
|
||||
.and_then(|widget| widget.size_hint(axis))
|
||||
.and_then(LayoutLen::declared)
|
||||
.and_then(|len| len.declared())
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -679,7 +679,7 @@ impl LayoutLen {
|
||||
/// the rule already gave the region its length, and the rule's length is
|
||||
/// what the widget reports there. And an axis the parent decided from
|
||||
/// the answer is the answer already.
|
||||
pub(super) fn fills(self, declared: Option<Len>, decided: bool) -> bool {
|
||||
pub(super) fn fills(&self, declared: Option<Len>, decided: bool) -> bool {
|
||||
self.leftover != Weight::ZERO || declared.is_some() || decided
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user