Factor out T_START from match statement

This commit is contained in:
Sujay Jayakar
2018-05-07 19:14:55 -07:00
parent 9f6cc853cc
commit 3156992b87
+5 -1
View File
@@ -82,6 +82,10 @@ const L_END: u32 = L_BASE + L_COUNT - 1;
const V_END: u32 = V_BASE + V_COUNT - 1;
const T_END: u32 = T_BASE + T_COUNT - 1;
// Composition only occurs for `TPart`s in `U+11A8 ... U+11C2`,
// i.e. `T_BASE + 1 ... T_END`.
const T_START: u32 = T_BASE + 1;
pub(crate) fn is_hangul_syllable(c: char) -> bool {
(c as u32) >= S_BASE && (c as u32) < (S_BASE + S_COUNT)
}
@@ -127,7 +131,7 @@ fn compose_hangul(a: char, b: char) -> Option<char> {
Some(unsafe {char::from_u32_unchecked(s)})
},
// Compose an LV_Syllable and a trailing consonant into an LVT_Syllable
(S_BASE ... S_END, T_BASE ... T_END) if (a - S_BASE) % T_COUNT == 0 && (b - T_BASE) > 0 => {
(S_BASE ... S_END, T_START ... T_END) if (a - S_BASE) % T_COUNT == 0 => {
Some(unsafe {char::from_u32_unchecked(a + (b - T_BASE))})
},
_ => None,