Skip to main content

UnconstrainedBox

Struct UnconstrainedBox 

Source
pub struct UnconstrainedBox;
Expand description

Lets its child be its natural size even where the parent offers less — and says so when that does not fit.

The child is laid out as if nothing were constraining it, and the box is as big as the child, up to the space it was itself offered. Where the child fits, nothing is unusual — the box is simply the child’s size, hugging it in a place that would have stretched it. Where it does not, the child is painted past the edges and a band says by how much, in debug builds.

ⓘ
// A row of chips that must not be squashed: too many, and the overflow is visible.
UnconstrainedBox::new(Flex::row().child(chip_a).child(chip_b))

That visible failure is the point, and the difference between this and OverflowBox, which spills on purpose and quietly. It is ConstraintsTransformBox with the constraint taken away, and nothing more.

UnconstrainedBox::axis frees one axis and leaves the other as it was, which is usually what is wanted: a paragraph that may be as tall as it likes is still as wide as its column.

Implementations§

Source§

impl UnconstrainedBox

Source

pub fn new<Msg: Clone + 'static>( child: impl Widget<Msg> + 'static, ) -> ConstraintsTransformBox<Msg>

Frees both axes.

Source

pub fn axis<Msg: Clone + 'static>( child: impl Widget<Msg> + 'static, axis: Axis, ) -> ConstraintsTransformBox<Msg>

Frees the given axis, and leaves the other one as the parent offered it.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<Msg> IntoMsg<Msg> for Msg

Source§

fn defer(work: impl Fn() -> Msg + 'static) -> Msg

The message that stands for work’s result.
Source§

impl<T> MaybeSend for T
where T: Send,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.