Enum text_layout::Item

source ·
pub enum Item {
    Box {
        width: f32,
    },
    Glue {
        width: f32,
        stretch: f32,
        shrink: f32,
    },
    Penalty {
        width: f32,
        cost: f32,
        flagged: bool,
    },
}
Expand description

A single item in a paragraph.

Variants§

§

Box

Fields

§width: f32

The width of the box.

An unbreakable box containing paragraph content. Typically represents a glyph or sequence of glyphs. Lines may not be broken at boxes.

§

Glue

Fields

§width: f32

The normal width of the whitespace.

§stretch: f32

The stretch parameter. If this item needs to be stretched in order to lay out a line, the stretch amount will be proportional to this value.

§shrink: f32

The shrink parameter. If this item needs to be shrunk in order to lay out a line, the shrink amount will be proportional to this value.

Whitespace that separates boxes. Lines may be broken at glue items.

§

Penalty

Fields

§width: f32

The width of the penalty item.

§cost: f32

The aesthetic cost of the penalty item. A high cost is a relatively undesirable breakpoint, while a low cost indicates a relatively desirable breakpoint.

§flagged: bool

Whether or not this is a flagged penalty item. Some algorithms will attempt to avoid having multiple consecutive breaks at flagged penalty items.

A penalty item. Represents a possible breakpoint with a particular aesthetic cost that indicates the desirability or undesirability of such a breakpoint.

Trait Implementations§

source§

impl Debug for Item

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl RefUnwindSafe for Item

§

impl Send for Item

§

impl Sync for Item

§

impl Unpin for Item

§

impl UnwindSafe for Item

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<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.