Skip to content

Commit b89118f

Browse files
committed
Nits
1 parent 49def3c commit b89118f

2 files changed

Lines changed: 46 additions & 49 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ keywords = ["unicode", "symbols"]
1313

1414
[features]
1515
default = ["numeral-systems", "styling"]
16-
numeral-systems = ["chinese-number"]
16+
numeral-systems = ["dep:chinese-number"]
1717
styling = []
1818
_test-unicode-conformance = ["ureq"]
1919

src/numeral_systems.rs

Lines changed: 45 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ declare_named! {
9292
///
9393
/// > 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11
9494
Arabic = "arabic" ("1"),
95+
9596
/// Circled decimal positional notation using
9697
/// [Western Arabic numerals](https://en.wikipedia.org/wiki/Arabic_numerals).
9798
///
@@ -105,6 +106,7 @@ declare_named! {
105106
///
106107
/// > ⓪, ①, ②, ③, ④, ⑤, ⑥, ⑦, ⑧, ⑨, ⑩, ⑪
107108
CircledArabic = "arabic.o" ("①"),
109+
108110
/// Double circled decimal positional notation using
109111
/// [Western Arabic numerals](https://en.wikipedia.org/wiki/Arabic_numerals).
110112
///
@@ -118,6 +120,7 @@ declare_named! {
118120
///
119121
/// > ⓵, ⓶, ⓷, ⓸, ⓹, ⓺, ⓻, ⓼, ⓽, ⓾
120122
DoubleCircledArabic = "arabic.oo" ("⓵"),
123+
121124
/// Lowercase
122125
/// [Latin letters](https://en.wikipedia.org/wiki/Latin_alphabet).
123126
///
@@ -132,6 +135,7 @@ declare_named! {
132135
/// > a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v,
133136
/// > w, x, y, z, aa, ab
134137
LowerLatin = "latin" ("a"),
138+
135139
/// Uppercase
136140
/// [Latin letters](https://en.wikipedia.org/wiki/Latin_alphabet).
137141
///
@@ -146,6 +150,7 @@ declare_named! {
146150
/// > A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V,
147151
/// > W, X, Y, Z, AA, AB
148152
UpperLatin = "Latin" ("A"),
153+
149154
/// Lowercase
150155
/// [Roman numerals](https://en.wikipedia.org/wiki/Roman_numerals).
151156
///
@@ -159,6 +164,7 @@ declare_named! {
159164
///
160165
/// > n, i, ii, iii, iv, v, vi, vii, viii, ix, x, xi
161166
LowerRoman = "roman" ("i"),
167+
162168
/// Uppercase
163169
/// [Roman numerals](https://en.wikipedia.org/wiki/Roman_numerals).
164170
///
@@ -172,6 +178,7 @@ declare_named! {
172178
///
173179
/// > N, I, II, III, IV, V, VI, VII, VIII, IX, X, XI
174180
UpperRoman = "Roman" ("I"),
181+
175182
/// Lowercase
176183
/// [Greek numerals](https://en.wikipedia.org/wiki/Greek_numerals).
177184
///
@@ -198,6 +205,7 @@ declare_named! {
198205
///
199206
/// > 𐆊, Α, Β, Γ, Δ, Ε, ΣΤ, Ζ, Η, Θ, Ι, ΙΑ, ΙΒ
200207
UpperGreek = "Greek" ("Α"),
208+
201209
/// Lowercase
202210
/// [Armenian numerals](https://en.wikipedia.org/wiki/Armenian_numerals).
203211
///
@@ -211,6 +219,7 @@ declare_named! {
211219
///
212220
/// > ա, բ, գ, դ, ե, զ, է, ը, թ, ժ, ժա, ժբ
213221
LowerArmenian = "armenian" ("ա"),
222+
214223
/// Uppercase
215224
/// [Armenian numerals](https://en.wikipedia.org/wiki/Armenian_numerals).
216225
///
@@ -224,6 +233,7 @@ declare_named! {
224233
///
225234
/// > Ա, Բ, Գ, Դ, Ե, Զ, Է, Ը, Թ, Ժ, ԺԱ, ԺԲ
226235
UpperArmenian = "Armenian" ("Ա"),
236+
227237
/// [Hebrew alphabetic numerals](https://en.wikipedia.org/wiki/Hebrew_numerals)
228238
/// without a
229239
/// [gershayim](https://en.wikipedia.org/wiki/Hebrew_numerals#Gershayim)
@@ -244,6 +254,7 @@ declare_named! {
244254
/// > <span dir="auto">ט</span>, <span dir="auto">י</span>,
245255
/// > <span dir="auto">יא</span>, <span dir="auto">יב</span>
246256
Hebrew = "hebrew" ("א"),
257+
247258
/// Everyday ordinary simplified
248259
/// [Chinese numerals](https://en.wikipedia.org/wiki/Chinese_numerals#Ordinary_numerals).
249260
///
@@ -257,6 +268,7 @@ declare_named! {
257268
///
258269
/// > 零, 一, 二, 三, 四, 五, 六, 七, 八, 九, 十, 十一, 十二
259270
LowerSimplifiedChinese = "chinese.simple" ("一"),
271+
260272
/// Financial ("capital") ordinary simplified
261273
/// [Chinese numerals](https://en.wikipedia.org/wiki/Chinese_numerals#Ordinary_numerals).
262274
///
@@ -270,6 +282,7 @@ declare_named! {
270282
///
271283
/// > 零, 壹, 贰, 叁, 肆, 伍, 陆, 柒, 捌, 玖, 拾, 拾壹, 拾贰
272284
UpperSimplifiedChinese = "Chinese.simple" ("壹"),
285+
273286
/// Everyday ordinary traditional
274287
/// [Chinese numerals](https://en.wikipedia.org/wiki/Chinese_numerals#Ordinary_numerals).
275288
///
@@ -283,6 +296,7 @@ declare_named! {
283296
///
284297
/// > 零, 一, 二, 三, 四, 五, 六, 七, 八, 九, 十, 十一, 十二
285298
LowerTraditionalChinese = "chinese.trad",
299+
286300
/// Financial ("capital") ordinary traditional
287301
/// [Chinese numerals](https://en.wikipedia.org/wiki/Chinese_numerals#Ordinary_numerals).
288302
///
@@ -296,6 +310,7 @@ declare_named! {
296310
///
297311
/// > 零, 壹, 貳, 參, 肆, 伍, 陸, 柒, 捌, 玖, 拾, 拾壹, 拾貳
298312
UpperTraditionalChinese = "Chinese.trad",
313+
299314
/// Hiragana in the gojūon order. Includes n but excludes wi and we.
300315
///
301316
/// ## Representable Numbers
@@ -308,6 +323,7 @@ declare_named! {
308323
///
309324
/// > あ, い, う, え, お, か, き, く, け, こ, さ, し
310325
HiraganaAiueo = "hiragana.aiueo" ("あ"),
326+
311327
/// Hiragana in the iroha order. Includes wi and we but excludes n.
312328
///
313329
/// ## Representable Numbers
@@ -320,6 +336,7 @@ declare_named! {
320336
///
321337
/// > い, ろ, は, に, ほ, へ, と, ち, り, ぬ, る, を
322338
HiraganaIroha = "hiragana.iroha" ("い"),
339+
323340
/// Katakana in the gojūon order. Includes n but excludes wi and we.
324341
///
325342
/// ## Representable Numbers
@@ -332,6 +349,7 @@ declare_named! {
332349
///
333350
/// > ア, イ, ウ, エ, オ, カ, キ, ク, ケ, コ, サ, シ
334351
KatakanaAiueo = "katakana.aiueo" ("ア"),
352+
335353
/// Katakana in the iroha order. Includes wi and we but excludes n.
336354
///
337355
/// ## Representable Numbers
@@ -344,6 +362,7 @@ declare_named! {
344362
///
345363
/// > イ, ロ, ハ, ニ, ホ, ヘ, ト, チ, リ, ヌ, ル, ヲ
346364
KatakanaIroha = "katakana.iroha" ("イ"),
365+
347366
// TODO: Improve Korean numeral systems based on https://github.com/typst/typst/issues/7335.
348367
/// Korean jamo.
349368
///
@@ -357,6 +376,7 @@ declare_named! {
357376
///
358377
/// > ㄱ, ㄴ, ㄷ, ㄹ, ㅁ, ㅂ, ㅅ, ㅇ, ㅈ, ㅊ, ㅋ, ㅌ
359378
KoreanJamo = "korean.jamo" ("ㄱ"),
379+
360380
/// Korean syllables.
361381
///
362382
/// ## Representable Numbers
@@ -369,6 +389,7 @@ declare_named! {
369389
///
370390
/// > 가, 나, 다, 라, 마, 바, 사, 아, 자, 차, 카, 타
371391
KoreanSyllable = "korean.syllable" ("가"),
392+
372393
/// Decimal positional notation using
373394
/// [Eastern Arabic numerals](https://en.wikipedia.org/wiki/Eastern_Arabic_numerals#Numerals).
374395
///
@@ -387,6 +408,7 @@ declare_named! {
387408
/// > <span dir="auto">٨</span>, <span dir="auto">٩</span>,
388409
/// > <span dir="auto">١٠</span>, <span dir="auto">١١</span>
389410
EasternArabic = "arabic.eastern" ("١"),
411+
390412
/// Decimal positional notation using the Persian variant of
391413
/// [Eastern Arabic numerals](https://en.wikipedia.org/wiki/Eastern_Arabic_numerals#Numerals).
392414
///
@@ -405,6 +427,7 @@ declare_named! {
405427
/// > <span dir="auto">۸</span>, <span dir="auto">۹</span>,
406428
/// > <span dir="auto">۱۰</span>, <span dir="auto">۱۱</span>
407429
Persian = "persian" ("۱"),
430+
408431
/// Decimal positional notation using
409432
/// [Devanagari numerals](https://en.wikipedia.org/wiki/Devanagari_numerals).
410433
///
@@ -418,6 +441,7 @@ declare_named! {
418441
///
419442
/// > ०, १, २, ३, ४, ५, ६, ७, ८, ९, १०, ११
420443
Devanagari = "devanagari" ("१"),
444+
421445
/// Decimal positional notation using
422446
/// [Bengali numerals](https://en.wikipedia.org/wiki/Bengali_numerals).
423447
///
@@ -431,6 +455,7 @@ declare_named! {
431455
///
432456
/// > ০, ১, ২, ৩, ৪, ৫, ৬, ৭, ৮, ৯, ১০, ১১
433457
Bengali = "bengali" ("১"),
458+
434459
/// Bengali letters.
435460
///
436461
/// ## Representable Numbers
@@ -443,6 +468,7 @@ declare_named! {
443468
///
444469
/// > ক, খ, গ, ঘ, ঙ, চ, ছ, জ, ঝ, ঞ, ট, ঠ
445470
BengaliLetters = "bengali.letter" ("ক"),
471+
446472
/// Repeating
447473
/// [note numbering symbols](https://en.wikipedia.org/wiki/Note_(typography)#Numbering_and_symbols).
448474
///
@@ -1337,8 +1363,8 @@ mod tests {
13371363
}
13381364
}
13391365

1340-
/// Compares the hashes of the first integers represented in each numeral
1341-
/// system to pre-computed values.
1366+
/// Compares the hashes of the first 50 thousand integers represented in
1367+
/// each numeral system to pre-computed values.
13421368
#[test]
13431369
fn test_numeral_systems() {
13441370
struct StableHasher(SipHasher13);
@@ -1360,70 +1386,41 @@ mod tests {
13601386
fn compute_hash(system: NamedNumeralSystem) -> u128 {
13611387
let mut state = StableHasher(SipHasher13::new());
13621388
for i in 0..50_000 {
1363-
system.system().represent(i).map(|r| r.to_string()).hash(&mut state)
1389+
system.system().represent(i).map(|r| r.to_string()).hash(&mut state);
13641390
}
13651391
state.0.finish128().as_u128()
13661392
}
13671393

1394+
#[rustfmt::skip]
13681395
fn expected_hash(system: NamedNumeralSystem) -> u128 {
13691396
match system {
13701397
NamedNumeralSystem::Arabic => 233363652923672209674688099512602556474,
1371-
NamedNumeralSystem::CircledArabic => {
1372-
14788096368351499805674874468259519865
1373-
}
1374-
NamedNumeralSystem::DoubleCircledArabic => {
1375-
84846816834872732753601089381949808193
1376-
}
1398+
NamedNumeralSystem::CircledArabic => 14788096368351499805674874468259519865,
1399+
NamedNumeralSystem::DoubleCircledArabic => 84846816834872732753601089381949808193,
13771400
NamedNumeralSystem::LowerLatin => 338462384600087330263193927875970822818,
13781401
NamedNumeralSystem::UpperLatin => 63389938855801182654207252735381557455,
13791402
NamedNumeralSystem::LowerRoman => 320120650624228984391933034556134697794,
13801403
NamedNumeralSystem::UpperRoman => 179137825631358807472580756311985798892,
13811404
NamedNumeralSystem::LowerGreek => 286426313636684184647936794996618738517,
13821405
NamedNumeralSystem::UpperGreek => 266767054320463395696526156316564222710,
1383-
NamedNumeralSystem::LowerArmenian => {
1384-
118575058866853099370711220898739682550
1385-
}
1386-
NamedNumeralSystem::UpperArmenian => {
1387-
14157728964774965650431335537322548529
1388-
}
1406+
NamedNumeralSystem::LowerArmenian => 118575058866853099370711220898739682550,
1407+
NamedNumeralSystem::UpperArmenian => 14157728964774965650431335537322548529,
13891408
NamedNumeralSystem::Hebrew => 206914675362605565607546884904163595545,
1390-
NamedNumeralSystem::LowerSimplifiedChinese => {
1391-
111467758380137268027180550654359765178
1392-
}
1393-
NamedNumeralSystem::UpperSimplifiedChinese => {
1394-
245480392218028497842549251253255025420
1395-
}
1396-
NamedNumeralSystem::LowerTraditionalChinese => {
1397-
335477487643271707320761870063839694075
1398-
}
1399-
NamedNumeralSystem::UpperTraditionalChinese => {
1400-
97580884915630322847859767213149399933
1401-
}
1402-
NamedNumeralSystem::HiraganaAiueo => {
1403-
228263127493940549113355043662499568034
1404-
}
1405-
NamedNumeralSystem::HiraganaIroha => {
1406-
223752166294897561554884466357640039672
1407-
}
1408-
NamedNumeralSystem::KatakanaAiueo => {
1409-
159989562581792168649789815071020535332
1410-
}
1411-
NamedNumeralSystem::KatakanaIroha => {
1412-
199999534019736521402858209442755367027
1413-
}
1409+
NamedNumeralSystem::LowerSimplifiedChinese => 111467758380137268027180550654359765178,
1410+
NamedNumeralSystem::UpperSimplifiedChinese => 245480392218028497842549251253255025420,
1411+
NamedNumeralSystem::LowerTraditionalChinese => 335477487643271707320761870063839694075,
1412+
NamedNumeralSystem::UpperTraditionalChinese => 97580884915630322847859767213149399933,
1413+
NamedNumeralSystem::HiraganaAiueo => 228263127493940549113355043662499568034,
1414+
NamedNumeralSystem::HiraganaIroha => 223752166294897561554884466357640039672,
1415+
NamedNumeralSystem::KatakanaAiueo => 159989562581792168649789815071020535332,
1416+
NamedNumeralSystem::KatakanaIroha => 199999534019736521402858209442755367027,
14141417
NamedNumeralSystem::KoreanJamo => 65477685939649764827530478995838083425, // 21
1415-
NamedNumeralSystem::KoreanSyllable => {
1416-
24217153056183571894327643661698510954
1417-
}
1418-
NamedNumeralSystem::EasternArabic => {
1419-
277754701051910363703826860323053920831
1420-
}
1418+
NamedNumeralSystem::KoreanSyllable => 24217153056183571894327643661698510954,
1419+
NamedNumeralSystem::EasternArabic => 277754701051910363703826860323053920831,
14211420
NamedNumeralSystem::Persian => 6232158096065129450489636457808686806,
14221421
NamedNumeralSystem::Devanagari => 327133969362282954753636774557232534052,
14231422
NamedNumeralSystem::Bengali => 79096832028418218544110224478554962928,
1424-
NamedNumeralSystem::BengaliLetters => {
1425-
269999388716378396079918080520770981179
1426-
}
1423+
NamedNumeralSystem::BengaliLetters => 269999388716378396079918080520770981179,
14271424
NamedNumeralSystem::Symbols => 88780534058354093087932015985325954737,
14281425
}
14291426
}

0 commit comments

Comments
 (0)