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
@@ -1167,7 +1167,7 @@ impl Size {
|
||||
/// in. Both are lengths of the window, so the comparison is in its
|
||||
/// pixels. A share is a length only to whoever divides one, so it is not
|
||||
/// a claim about this box and cannot exceed it.
|
||||
fn within_box(self, region: UiRegion, window: PxVec2, axis: Axis) -> bool {
|
||||
fn within_box(&self, region: UiRegion, window: PxVec2, axis: Axis) -> bool {
|
||||
let len = self[axis];
|
||||
let window = window[axis];
|
||||
len.leftover != Weight::ZERO
|
||||
|
||||
Reference in new issue
Block a user