8000 Use `..=` syntax for inclusive ranges · unicode-rs/unicode-normalization@42fd2c1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 42fd2c1

Browse files
Use ..= syntax for inclusive ranges
1 parent 061dc3c commit 42fd2c1

File tree

3 files changed

+647
-647
lines changed

3 files changed

+647
-647
lines changed

scripts/unicode.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ def gen_qc_match(prop_table, out):
419419
assert data in ('N', 'M')
420420
result = "No" if data == 'N' else "Maybe"
421421
if high:
422-
out.write(r" '\u{%s}'...'\u{%s}' => %s," % (low, high, result))
422+
out.write(r" '\u{%s}'..='\u{%s}' => %s," % (low, high, result))
423423
else:
424424
out.write(r" '\u{%s}' => %s," % (low, result))
425425
out.write("\n")

src/normalize.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ const L_LAST: u32 = L_BASE + L_COUNT - 1;
123123
const V_LAST: u32 = V_BASE + V_COUNT - 1;
124124
const T_LAST: u32 = T_BASE + T_COUNT - 1;
125125

126-
// Composition only occurs for `TPart`s in `U+11A8 ... U+11C2`,
127-
// i.e. `T_BASE + 1 ... T_LAST`.
126+
// Composition only occurs for `TPart`s in `U+11A8 ..= U+11C2`,
127+
// i.e. `T_BASE + 1 ..= T_LAST`.
128128
const T_FIRST: u32 = T_BASE + 1;
129129

130130
pub(crate) fn is_hangul_syllable(c: char) -> bool {
@@ -172,15 +172,15 @@ fn compose_hangul(a: char, b: char) -> Option<char> {
172172
let (a, b) = (a as u32, b as u32);
173173
match (a, b) {
174174
// Compose a leading consonant and a vowel together into an LV_Syllable
175-
(L_BASE...L_LAST, V_BASE...V_LAST) => {
175+
(L_BASE..=L_LAST, V_BASE..=V_LAST) => {
176176
let l_index = a - L_BASE;
177177
let v_index = b - V_BASE;
178178
let lv_index = l_index * N_COUNT + v_index * T_COUNT;
179179
let s = S_BASE + lv_index;
180180
Some(unsafe { char::from_u32_unchecked(s) })
181181
}
182182
// Compose an LV_Syllable and a trailing consonant into an LVT_Syllable
183-
(S_BASE...S_LAST, T_FIRST...T_LAST) if (a - S_BASE) % T_COUNT == 0 => {
183+
(S_BASE..=S_LAST, T_FIRST..=T_LAST) if (a - S_BASE) % T_COUNT == 0 => {
184184
Some(unsafe { char::from_u32_unchecked(a + (b - T_BASE)) })
185185
}
186186
_ => None,
@@ -193,7 +193,7 @@ mod tests {
193193

194194
// Regression test from a bugfix where we were composing an LV_Syllable with
195195
// T_BASE directly. (We should only compose an LV_Syllable with a character
196-
// in the range `T_BASE + 1 ... T_LAST`.)
196+
// in the range `T_BASE + 1 ..= T_LAST`.)
197197
#[test]
198198
fn test_hangul_composition() {
199199
assert_eq!(compose_hangul('\u{c8e0}', '\u{11a7}'), None);

0 commit comments

Comments
 (0)
0