[−][src]Struct textwrap::core::Word
A piece of wrappable text, including any trailing whitespace.
A Word
is an example of a Fragment
, so it has a width,
trailing whitespace, and potentially a penalty item.
Fields
word: &'a str
Word content.
whitespace: &'a str
Whitespace to insert if the word does not fall at the end of a line.
penalty: &'a str
Penalty string to insert if the word falls at the end of a line.
Implementations
impl<'a> Word<'a>
[src]
pub fn from(word: &str) -> Word<'_>
[src]
Construct a Word
from a string.
A trailing stretch of ' '
is automatically taken to be the
whitespace part of the word.
pub fn break_apart<'b>(
&'b self,
line_width: usize
) -> impl Iterator<Item = Word<'a>> + 'b
[src]
&'b self,
line_width: usize
) -> impl Iterator<Item = Word<'a>> + 'b
Break this word into smaller words with a width of at most
line_width
. The whitespace and penalty from this Word
is
added to the last piece.
Examples
use textwrap::core::Word; assert_eq!( Word::from("Hello! ").break_apart(3).collect::<Vec<_>>(), vec![Word::from("Hel"), Word::from("lo! ")] );
Trait Implementations
impl<'a> Clone for Word<'a>
[src]
impl<'a> Copy for Word<'a>
[src]
impl<'a> Debug for Word<'a>
[src]
impl<'_> Deref for Word<'_>
[src]
impl<'a> Eq for Word<'a>
[src]
impl<'_> Fragment for Word<'_>
[src]
fn width(&self) -> usize
[src]
fn whitespace_width(&self) -> usize
[src]
fn penalty_width(&self) -> usize
[src]
impl<'a> PartialEq<Word<'a>> for Word<'a>
[src]
impl<'a> StructuralEq for Word<'a>
[src]
impl<'a> StructuralPartialEq for Word<'a>
[src]
Auto Trait Implementations
impl<'a> RefUnwindSafe for Word<'a>
impl<'a> Send for Word<'a>
impl<'a> Sync for Word<'a>
impl<'a> Unpin for Word<'a>
impl<'a> UnwindSafe for Word<'a>
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>,