pub struct Pyphen { /* private fields */ }
Expand description
Hyphenation class, with methods to hyphenate strings in various ways.
Implementations§
Source§impl Pyphen
impl Pyphen
Sourcepub fn positions(&self, word: &str) -> Vec<DataInt>
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
Sourcepub fn iterate<'b>(&self, word: &'b str) -> Iter<'b> ⓘ
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
Sourcepub fn wrap_with<'b>(
&self,
word: &'b str,
width: usize,
hyphen: &str,
) -> Option<(String, Cow<'b, str>)>
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
Sourcepub fn wrap<'b>(
&self,
word: &'b str,
width: usize,
) -> Option<(String, Cow<'b, str>)>
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
Sourcepub fn inserted_with(&self, word: &str, hyphen: &str) -> String
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");
Sourcepub fn inserted(&self, word: &str) -> String
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");