Rename the Sized widget to SetSize
It shadowed the marker trait, so a `?Sized` bound in any crate that imports the prelude failed to resolve -- a compile error in someone else's code that nothing here would have caught. Three files inside iris already imported `std::marker::Sized` to get out from under it; they no longer need to. `SetSize` rather than `FixedSize` because the size it sets need not be fixed: `width(rest(2))` and `width(rel(0.5))` build the same widget. It pairs with the `MaxSize` beside it -- one sets a length, the other caps it. `tests/prelude_bounds.rs` is a compile-level guard: it fails to build if the prelude shadows `Sized` again. The pad tab of the tabs example, which is what uses `sized` and the flexible widths, renders pixel-identical. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
00d2230b84
commit
f312db60c2
7 files changed
+27
-18
No files matched your search
@@ -0,0 +1,13 @@
|
||||
//! The prelude must not shadow names from the standard prelude. A widget
|
||||
//! called `Sized` meant every `?Sized` bound in a crate using iris resolved
|
||||
//! to the widget and failed to compile, which is an error in someone else's
|
||||
//! code that nothing here would have noticed.
|
||||
|
||||
use iris::prelude::*;
|
||||
|
||||
fn takes_unsized<T: ?Sized>(_: &T) {}
|
||||
|
||||
#[test]
|
||||
fn the_prelude_leaves_sized_alone() {
|
||||
takes_unsized("a `?Sized` bound resolves to the marker trait");
|
||||
}
|
||||
Reference in new issue
Block a user