Say from_axes, which is what a constructor is called
`per_axis` on `PlaceDesc` and `Declared` builds a pair by asking for each axis. `from_axis` beside it already names the three-argument form, so the plural is the one that takes a function, and both follow Rust's convention for a constructor rather than an invented word. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4d42f1c8ca
commit
40b89c1f79
4 files changed
+4
-4
No files matched your search
@@ -648,7 +648,7 @@ impl Widgets {
|
||||
pub(crate) fn declared_lens(&self, id: WidgetId) -> Declared {
|
||||
let rules = self.size_rules(id);
|
||||
let widget = self.get_dyn(id);
|
||||
Declared::per_axis(|axis| {
|
||||
Declared::from_axes(|axis| {
|
||||
rules[axis].declared().or_else(|| {
|
||||
// A hint still narrows the box where no rule does, which is
|
||||
// how a widget with a natural pixel size -- an image, a gap
|
||||
|
||||
@@ -147,7 +147,7 @@ impl PlaceDesc {
|
||||
|
||||
/// A description per axis, where the two differ and neither is the
|
||||
/// axis a container divides.
|
||||
pub fn per_axis(f: impl Fn(Axis) -> PlaceDescAxis) -> Self {
|
||||
pub fn from_axes(f: impl Fn(Axis) -> PlaceDescAxis) -> Self {
|
||||
Self::new(f(Axis::X), f(Axis::Y))
|
||||
}
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ pub struct Declared {
|
||||
impl Declared {
|
||||
pub const NONE: Self = Self { x: None, y: None };
|
||||
|
||||
pub fn per_axis(f: impl Fn(Axis) -> Option<Len>) -> Self {
|
||||
pub fn from_axes(f: impl Fn(Axis) -> Option<Len>) -> Self {
|
||||
Self {
|
||||
x: f(Axis::X),
|
||||
y: f(Axis::Y),
|
||||
|
||||
@@ -31,7 +31,7 @@ impl Widget for Stack {
|
||||
// fraction under them is a fraction of it. A share leaves the axis
|
||||
// to whoever gave the stack its box. Where a child sits in a box
|
||||
// bigger than itself is its own business.
|
||||
let place = PlaceDesc::per_axis(|axis| {
|
||||
let place = PlaceDesc::from_axes(|axis| {
|
||||
let len = size[axis];
|
||||
match len.leftover == Weight::ZERO {
|
||||
true => len.without_leftover().as_desc().fills(),
|
||||
|
||||
Reference in new issue
Block a user