Struct Pyphen

Source
pub struct Pyphen { /* private fields */ }
Expand description

Hyphenation class, with methods to hyphenate strings in various ways.

Implementations§

Source§

impl Pyphen

Source

pub fn positions(&self, word: &str) -> Vec<DataInt>

Get a list of positions where the word can be hyphenated. The points that are too far to the left or right are removed.

  • word - unicode string of the word to hyphenate
Source

pub fn iterate<'b>(&self, word: &'b str) -> Iter<'b>

Iterate over all hyphenation possibilities, the longest first.

  • word - unicode string of the word to hyphenate
Source

pub fn wrap_with<'b>( &self, word: &'b str, width: usize, hyphen: &str, ) -> Option<(String, Cow<'b, str>)>

Get the longest possible first part and the last part of a word.

The first part has the hyphen already attached.

Returns None if there is no hyphenation point before width, or if the word could not be hyphenated.

  • word - unicode string of the word to hyphenate
  • width - maximum length of the first part
  • hyphen - unicode string used as hyphen character
Source

pub fn wrap<'b>( &self, word: &'b str, width: usize, ) -> Option<(String, Cow<'b, str>)>

Get the longest possible first part and the last part of a word.

The first part has the hyphen already attached.

Returns None if there is no hyphenation point before width, or if the word could not be hyphenated.

  • word - unicode string of the word to hyphenate
  • width - maximum length of the first part
Source

pub fn inserted_with(&self, word: &str, hyphen: &str) -> String

Get the word as a string with all the possible hyphens inserted.

  • word - unicode string of the word to hyphenate
  • hyphen - unicode string used as hyphen character
§Example
use pyphen_rs::Builder;

let dic = Builder::lang("nl_NL").build().unwrap();

assert_eq!(dic.inserted_with("lettergrepen", "."), "let.ter.gre.pen");
Source

pub fn inserted(&self, word: &str) -> String

Get the word as a string with all the possible hyphens inserted.

  • word - unicode string of the word to hyphenate
§Example
use pyphen_rs::Builder;

let dic = Builder::lang("nl_NL").build().unwrap();

assert_eq!(dic.inserted("lettergrepen"), "let-ter-gre-pen");

Auto Trait Implementations§

§

impl Freeze for Pyphen

§

impl !RefUnwindSafe for Pyphen

§

impl !Send for Pyphen

§

impl !Sync for Pyphen

§

impl Unpin for Pyphen

§

impl !UnwindSafe for Pyphen

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>,

Source§

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>,

Source§

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.