Skip to content

Commit df802a2

Browse files
Florobalexcrichton
authored andcommitted
std: Rename str::Normalizations to str::Decompositions
The Normalizations iterator has been renamed to Decompositions. It does not currently include all forms of Unicode normalization, but only encompasses decompositions. If implemented recomposition would likely be a separate iterator which works on the result of this one. [breaking-change]
1 parent 8c54d5b commit df802a2

File tree

5 files changed

+26
-26
lines changed

5 files changed

+26
-26
lines changed

src/etc/unicode.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -256,13 +256,13 @@ def format_table_content(f, content, indent):
256256
line = " "*indent + chunk
257257
f.write(line)
258258

259-
def emit_core_decomp_module(f, canon, compat):
259+
def emit_core_norm_module(f, canon, compat):
260260
canon_keys = canon.keys()
261261
canon_keys.sort()
262262

263263
compat_keys = compat.keys()
264264
compat_keys.sort()
265-
f.write("pub mod decompose {\n");
265+
f.write("pub mod normalization {\n");
266266
f.write(" use option::Option;\n");
267267
f.write(" use option::{Some, None};\n");
268268
f.write(" use slice::ImmutableVector;\n");
@@ -401,8 +401,8 @@ def emit_core_decomp_module(f, canon, compat):
401401
402402
""")
403403

404-
def emit_std_decomp_module(f, combine):
405-
f.write("pub mod decompose {\n");
404+
def emit_std_norm_module(f, combine):
405+
f.write("pub mod normalization {\n");
406406
f.write(" use option::{Some, None};\n");
407407
f.write(" use slice::ImmutableVector;\n");
408408

@@ -467,7 +467,7 @@ def gen_core_unicode():
467467
emit_bsearch_range_table(rf);
468468
emit_property_module(rf, "general_category", gencats)
469469

470-
emit_core_decomp_module(rf, canon_decomp, compat_decomp)
470+
emit_core_norm_module(rf, canon_decomp, compat_decomp)
471471

472472
derived = load_properties("DerivedCoreProperties.txt",
473473
["XID_Start", "XID_Continue", "Alphabetic", "Lowercase", "Uppercase"])
@@ -485,7 +485,7 @@ def gen_std_unicode():
485485
with open(r, "w") as rf:
486486
# Preamble
487487
rf.write(preamble)
488-
emit_std_decomp_module(rf, combines)
488+
emit_std_norm_module(rf, combines)
489489

490490
gen_core_unicode()
491491
gen_std_unicode()

src/libcore/char.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ use iter::{Iterator, range_step};
3030
use unicode::{derived_property, property, general_category, conversions};
3131

3232
/// Returns the canonical decomposition of a character.
33-
pub use unicode::decompose::decompose_canonical;
33+
pub use unicode::normalization::decompose_canonical;
3434
/// Returns the compatibility decomposition of a character.
35-
pub use unicode::decompose::decompose_compatible;
35+
pub use unicode::normalization::decompose_compatible;
3636

3737
#[cfg(not(test))] use cmp::{Eq, Ord, TotalEq, TotalOrd, Ordering};
3838
#[cfg(not(test))] use default::Default;

src/libcore/unicode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ pub mod general_category {
104104

105105
}
106106

107-
pub mod decompose {
107+
pub mod normalization {
108108
use option::Option;
109109
use option::{Some, None};
110110
use slice::ImmutableVector;

src/libstd/str.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -228,25 +228,25 @@ fn canonical_sort(comb: &mut [(char, u8)]) {
228228
}
229229

230230
#[deriving(Clone)]
231-
enum NormalizationForm {
232-
NFD,
233-
NFKD
231+
enum DecompositionType {
232+
Canonical,
233+
Compatible
234234
}
235235

236-
/// External iterator for a string's normalization's characters.
236+
/// External iterator for a string's decomposition's characters.
237237
/// Use with the `std::iter` module.
238238
#[deriving(Clone)]
239-
pub struct Normalizations<'a> {
240-
kind: NormalizationForm,
239+
pub struct Decompositions<'a> {
240+
kind: DecompositionType,
241241
iter: Chars<'a>,
242242
buffer: Vec<(char, u8)>,
243243
sorted: bool
244244
}
245245

246-
impl<'a> Iterator<char> for Normalizations<'a> {
246+
impl<'a> Iterator<char> for Decompositions<'a> {
247247
#[inline]
248248
fn next(&mut self) -> Option<char> {
249-
use unicode::decompose::canonical_combining_class;
249+
use unicode::normalization::canonical_combining_class;
250250

251251
match self.buffer.as_slice().head() {
252252
Some(&(c, 0)) => {
@@ -262,8 +262,8 @@ impl<'a> Iterator<char> for Normalizations<'a> {
262262
}
263263

264264
let decomposer = match self.kind {
265-
NFD => char::decompose_canonical,
266-
NFKD => char::decompose_compatible
265+
Canonical => char::decompose_canonical,
266+
Compatible => char::decompose_compatible
267267
};
268268

269269
if !self.sorted {
@@ -887,24 +887,24 @@ pub trait StrAllocating: Str {
887887
/// An Iterator over the string in Unicode Normalization Form D
888888
/// (canonical decomposition).
889889
#[inline]
890-
fn nfd_chars<'a>(&'a self) -> Normalizations<'a> {
891-
Normalizations {
890+
fn nfd_chars<'a>(&'a self) -> Decompositions<'a> {
891+
Decompositions {
892892
iter: self.as_slice().chars(),
893893
buffer: Vec::new(),
894894
sorted: false,
895-
kind: NFD
895+
kind: Canonical
896896
}
897897
}
898898

899899
/// An Iterator over the string in Unicode Normalization Form KD
900900
/// (compatibility decomposition).
901901
#[inline]
902-
fn nfkd_chars<'a>(&'a self) -> Normalizations<'a> {
903-
Normalizations {
902+
fn nfkd_chars<'a>(&'a self) -> Decompositions<'a> {
903+
Decompositions {
904904
iter: self.as_slice().chars(),
905905
buffer: Vec::new(),
906906
sorted: false,
907-
kind: NFKD
907+
kind: Compatible
908908
}
909909
}
910910
}

src/libstd/unicode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
#![allow(missing_doc, non_uppercase_statics)]
1414

15-
pub mod decompose {
15+
pub mod normalization {
1616
use option::{Some, None};
1717
use slice::ImmutableVector;
1818

0 commit comments

Comments
 (0)