Four rounds over the same idea: an expression that needed a comment to say
what it computed wanted to be a named operation.
The placement description is built by chaining off the value that says it.
`UiSpan::within_desc`/`shifted_desc` and `Len::as_desc` replace the
`PlaceDescAxis::` constructors, `PlaceDescAxis::axis` lifts one axis into a
pair with the whole box across it, and `PlaceDesc::per_axis` covers the case
where the two axes differ. `beside` is dropped: `from_axis` already said it.
Seven module-level functions become methods on the value each took first --
`Widgets::declared_lens`, `LayoutLen::fills`, `PlaceDesc::placement` and
`::rel_base_and_region`, `Size::within_box`, `UiRegion::at_origin` and
`::as_translation`.
`UiSpan::place` is the aligned-placement rule, which was written out three
times; `LayoutLen::without_leftover` is the sibling `apply_leftover` never
had, at six sites; `is_px` and `is_only_leftover` name field comparisons the
surrounding comments had to translate; `Holds::covers` was interval
containment spelled out by hand. A span's `shared` loses the two arguments
that did not vary across its loop.
`LayoutHolds` was four two-element arrays where every other pair here is a
struct of two per-axis values, so nothing it did could be written once.
It becomes `AxisHolds` on `x` and `y`, and `and`, `covers` and `contains`
lose their loops.
Every pair gets `Index<Axis>`/`IndexMut<Axis>` through one macro, and the
eighteen `axis`/`axis_mut` methods go. `const_index` keeps the accessors
usable in const context.
Cold layout is unchanged: `layout_dump` over 400 depth-5 trees is identical
to 58ce74d byte for byte, across all 34,492 boxes.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
40 lines
746 B
Rust
40 lines
746 B
Rust
#![feature(macro_metavar_expr_concat)]
|
|
#![feature(const_ops)]
|
|
#![feature(const_trait_impl)]
|
|
#![feature(const_convert)]
|
|
#![feature(unboxed_closures)]
|
|
#![feature(fn_traits)]
|
|
#![feature(const_destruct)]
|
|
#![feature(associated_type_defaults)]
|
|
#![feature(unsize)]
|
|
#![feature(coerce_unsized)]
|
|
#![feature(option_into_flat_iter)]
|
|
#![feature(const_index)]
|
|
|
|
#[cfg(feature = "layout-diagnostics")]
|
|
pub mod layout_diagnostics;
|
|
|
|
mod attr;
|
|
mod event;
|
|
mod fixed;
|
|
mod num;
|
|
mod orientation;
|
|
mod primitive;
|
|
mod render;
|
|
mod ui;
|
|
mod widget;
|
|
|
|
pub mod util;
|
|
|
|
pub use attr::*;
|
|
pub use event::*;
|
|
pub use fixed::*;
|
|
pub use num::*;
|
|
pub use orientation::*;
|
|
pub use primitive::*;
|
|
pub use render::*;
|
|
pub use ui::*;
|
|
pub use widget::*;
|
|
|
|
pub type UiColor = primitive::Color<u8>;
|