Trait pinyin::ToPinyinMulti

source ·
pub trait ToPinyinMulti {
    type Output;

    // Required method
    fn to_pinyin_multi(&self) -> Self::Output;
}
Expand description

用于获取多音字信息的trait

仅在启用 heteronym 特性时可用

Required Associated Types§

Required Methods§

source

fn to_pinyin_multi(&self) -> Self::Output

Implementations on Foreign Types§

source§

impl<'a> ToPinyinMulti for &'a str

use pinyin::{Pinyin, ToPinyinMulti};
let mut iter = "还没".to_pinyin_multi();
let mut next_heteronym = || {
    iter.next()
        .and_then(|m| m)
        .map(|m| m.into_iter().map(Pinyin::with_tone).collect::<Vec<_>>())
};
assert_eq!(next_heteronym(), Some(vec!["hái", "huán", "fú"]));
assert_eq!(next_heteronym(), Some(vec!["méi", "mò", "me"]));
assert_eq!(next_heteronym(), None);
source§

impl ToPinyinMulti for char

use pinyin::{Pinyin, ToPinyinMulti};
let mut iter = '还'.to_pinyin_multi().unwrap().into_iter();
let mut next_pinyin = || iter.next().map(Pinyin::with_tone);
assert_eq!(next_pinyin(), Some("hái"));
assert_eq!(next_pinyin(), Some("huán"));
assert_eq!(next_pinyin(), Some("fú"));
assert_eq!(next_pinyin(), None);

Implementors§