pub struct BoxElement<'s> { /* private fields */ }Expand description
An element with its type erased.
This type can be used to return multiple kinds of elements from a function.
§Example
use line_ui::element::{BoxElement, IntoElement};
use line_ui::{Color, Style};
fn foo(value: bool) -> BoxElement<'static> {
if value {
"some fancy text"
.fixed_width(20)
.styled(Style::fg(Color::RED) + Style::INVERT)
.boxed()
} else {
"just some text".boxed()
}
}Implementations§
Trait Implementations§
Auto Trait Implementations§
impl<'s> Freeze for BoxElement<'s>
impl<'s> RefUnwindSafe for BoxElement<'s>
impl<'s> Send for BoxElement<'s>
impl<'s> Sync for BoxElement<'s>
impl<'s> Unpin for BoxElement<'s>
impl<'s> UnwindSafe for BoxElement<'s>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<'s, E> IntoElement<'s> for Ewhere
E: Element<'s>,
impl<'s, E> IntoElement<'s> for Ewhere
E: Element<'s>,
Source§type ElementType = E
type ElementType = E
The element type to be converted into.
Source§fn into_element(self) -> <E as IntoElement<'s>>::ElementType
fn into_element(self) -> <E as IntoElement<'s>>::ElementType
Converts this type into an
Element.Source§fn fixed_width(self, width: usize) -> FixedWidth<Self::ElementType>
fn fixed_width(self, width: usize) -> FixedWidth<Self::ElementType>
Convenience function to wrap this element in a
FixedWidth.Source§fn styled(self, style: Style) -> Styled<Self::ElementType>
fn styled(self, style: Style) -> Styled<Self::ElementType>
Convenience function to wrap this element in a
Styled.Source§fn boxed(self) -> BoxElement<'s>
fn boxed(self) -> BoxElement<'s>
Convenience function to box this element.