From a5f89ddcabefc4f490f118cb174d621343ad23cb Mon Sep 17 00:00:00 2001 From: Xidorn Quan Date: Sat, 1 Jun 2019 20:10:06 +1000 Subject: [PATCH] =?UTF-8?q?=E7=AE=80=E5=8C=96PinyinMulti::get=5Fopt?= =?UTF-8?q?=E7=9A=84=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pinyin_multi.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/pinyin_multi.rs b/src/pinyin_multi.rs index 4d277b2..7622090 100644 --- a/src/pinyin_multi.rs +++ b/src/pinyin_multi.rs @@ -26,12 +26,11 @@ impl PinyinMulti { /// 获取指定序号的拼音,如果序号超过总数则返回 `None` pub fn get_opt(self, idx: usize) -> Option { 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()])) } }