pub struct HyphenationDict {
pub language: String,
pub left_min: usize,
pub right_min: usize,
/* private fields */
}Expand description
A hyphenation dictionary for a specific language.
Contains compiled patterns in a trie and an exception list for words whose hyphenation deviates from the pattern rules.
Fields§
§language: StringISO 639-1 language code (e.g. “en”, “de”).
left_min: usizeMinimum prefix before first break.
right_min: usizeMinimum suffix after last break.
Implementations§
Source§impl HyphenationDict
impl HyphenationDict
Sourcepub fn new(language: &str, patterns: &[&str], exceptions: &[&str]) -> Self
pub fn new(language: &str, patterns: &[&str], exceptions: &[&str]) -> Self
Create a dictionary from raw TeX-format pattern strings and exception words.
Patterns use TeX notation (e.g. "hy3p", ".ex5am").
Exceptions use hyphen-delimited words (e.g. "hy-phen-ation").
Sourcepub fn with_margins(self, left: usize, right: usize) -> Self
pub fn with_margins(self, left: usize, right: usize) -> Self
Set custom left/right minimum margins.
Sourcepub fn hyphenate(&self, word: &str) -> Vec<HyphenBreakPoint>
pub fn hyphenate(&self, word: &str) -> Vec<HyphenBreakPoint>
Find all valid hyphenation points in a word.
Returns break points sorted by offset. The word should be a single whitespace-free token (not a phrase or sentence).
Sourcepub fn can_hyphenate(&self, word: &str) -> bool
pub fn can_hyphenate(&self, word: &str) -> bool
Check if a word has any valid hyphenation points.
Trait Implementations§
Source§impl Clone for HyphenationDict
impl Clone for HyphenationDict
Source§fn clone(&self) -> HyphenationDict
fn clone(&self) -> HyphenationDict
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for HyphenationDict
impl RefUnwindSafe for HyphenationDict
impl Send for HyphenationDict
impl Sync for HyphenationDict
impl Unpin for HyphenationDict
impl UnwindSafe for HyphenationDict
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more