Skip to content

Commit

Permalink
Merge branch 'develop' into tests
Browse files Browse the repository at this point in the history
  • Loading branch information
upsuper committed Jun 1, 2019
2 parents 7da51bf + a5f89dd commit cfe11da
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/pinyin_multi.rs
Expand Up @@ -26,12 +26,11 @@ impl PinyinMulti {
/// 获取指定序号的拼音,如果序号超过总数则返回 `None`
pub fn get_opt(self, idx: usize) -> Option<Pinyin> {
if idx == 0 {
Some(Pinyin(self.first))
} else {
self.other_indexes
.get(usize::try_from(idx).unwrap() - 1)
.map(|i| Pinyin(&PINYIN_DATA[usize::try_from(*i).unwrap()]))
return Some(Pinyin(self.first));
}
self.other_indexes
.get(usize::try_from(idx).unwrap() - 1)
.map(|i| Pinyin(&PINYIN_DATA[usize::try_from(*i).unwrap()]))
}
}

Expand Down

0 comments on commit cfe11da

Please sign in to comment.