[][src]Trait pinyin::ToPinyinMulti

pub trait ToPinyinMulti {
    type Output;
    fn to_pinyin_multi(&self) -> Self::Output;
}

用于获取多音字信息的trait

仅在启用 heteronym 特性时可用

Associated Types

type Output

Loading content...

Required methods

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

Loading content...

Implementations on Foreign Types

impl ToPinyinMulti for char[src]

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("fú"));
assert_eq!(next_pinyin(), Some("huán"));
assert_eq!(next_pinyin(), None);

impl<'a> ToPinyinMulti for &'a str[src]

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", "fú", "huán"]));
assert_eq!(next_heteronym(), Some(vec!["méi", "mò", "me"]));
assert_eq!(next_heteronym(), None);
Loading content...

Implementors

Loading content...