pub enum WrapAlgorithm {
    OptimalFit,
    FirstFit,
}
Expand description

Wrapping algorithms.

After a text has been broken into Fragments, the one now has to decide how to break the fragments into lines. The simplest algorithm for this is implemented by wrap_first_fit: it uses no look-ahead and simply adds fragments to the line as long as they fit. However, this can lead to poor line breaks if a large fragment almost-but-not-quite fits on a line. When that happens, the fragment is moved to the next line and it will leave behind a large gap. A more advanced algorithm, implemented by wrap_optimal_fit, will take this into account. The optimal-fit algorithm considers all possible line breaks and will attempt to minimize the gaps left behind by overly short lines.

While both algorithms run in linear time, the first-fit algorithm is about 4 times faster than the optimal-fit algorithm.

Variants§

§

OptimalFit

Use an advanced algorithm which considers the entire paragraph to find optimal line breaks. Implemented by wrap_optimal_fit.

Note: Only available when the smawk Cargo feature is enabled.

§

FirstFit

Use a fast and simple algorithm with no look-ahead to find line breaks. Implemented by wrap_first_fit.

Trait Implementations§

source§

impl Clone for WrapAlgorithm

source§

fn clone(&self) -> WrapAlgorithm

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for WrapAlgorithm

source§

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

Formats the value using the given formatter. Read more
source§

impl PartialEq<WrapAlgorithm> for WrapAlgorithm

source§

fn eq(&self, other: &WrapAlgorithm) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for WrapAlgorithm

source§

impl Eq for WrapAlgorithm

source§

impl StructuralEq for WrapAlgorithm

source§

impl StructuralPartialEq for WrapAlgorithm

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.