[−][src]Enum textwrap::core::WrapAlgorithm
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
Use an advanced algorithm which considers the entire paragraph
to find optimal line breaks. Implemented by
wrap_optimal_fit.
Use a fast and simple algorithm with no look-ahead to find
line breaks. Implemented by wrap_first_fit.
Trait Implementations
impl Clone for WrapAlgorithm[src]
fn clone(&self) -> WrapAlgorithm[src]
fn clone_from(&mut self, source: &Self)1.0.0[src]
impl Copy for WrapAlgorithm[src]
impl Debug for WrapAlgorithm[src]
impl Eq for WrapAlgorithm[src]
impl PartialEq<WrapAlgorithm> for WrapAlgorithm[src]
fn eq(&self, other: &WrapAlgorithm) -> bool[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool1.0.0[src]
impl StructuralEq for WrapAlgorithm[src]
impl StructuralPartialEq for WrapAlgorithm[src]
Auto Trait Implementations
impl RefUnwindSafe for WrapAlgorithm
impl Send for WrapAlgorithm
impl Sync for WrapAlgorithm
impl Unpin for WrapAlgorithm
impl UnwindSafe for WrapAlgorithm
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T[src]
pub fn clone_into(&self, target: &mut T)[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,