Skip to content

Commit 688b623

Browse files
committed
Auto merge of rust-lang#26561 - SimonSapin:remove-titlecase, r=alexcrichton
I added it because it was easy (same a `char::to_lowercase`, just a different table), but it doesn’t make sense to have this in std but not str::to_titlecase, which would require https://github.com/unicode-rs/unicode-segmentation At some point in the future this feature will be available (both on char and str) in a crates.io crate.
2 parents 124d165 + 32b7b50 commit 688b623

File tree

4 files changed

+0
-586
lines changed

4 files changed

+0
-586
lines changed

src/etc/unicode.py

-10
Original file line numberDiff line numberDiff line change
@@ -372,13 +372,6 @@ def emit_conversions_module(f, to_upper, to_lower, to_title):
372372
}
373373
}
374374
375-
pub fn to_title(c: char) -> [char; 3] {
376-
match bsearch_case_table(c, to_titlecase_table) {
377-
None => [c, '\\0', '\\0'],
378-
Some(index) => to_titlecase_table[index].1
379-
}
380-
}
381-
382375
fn bsearch_case_table(c: char, table: &'static [(char, [char; 3])]) -> Option<usize> {
383376
match table.binary_search_by(|&(key, _)| {
384377
if c == key { Equal }
@@ -400,9 +393,6 @@ def emit_conversions_module(f, to_upper, to_lower, to_title):
400393
emit_table(f, "to_uppercase_table",
401394
sorted(to_upper.iteritems(), key=operator.itemgetter(0)),
402395
is_pub=False, t_type = t_type, pfun=pfun)
403-
emit_table(f, "to_titlecase_table",
404-
sorted(to_title.iteritems(), key=operator.itemgetter(0)),
405-
is_pub=False, t_type = t_type, pfun=pfun)
406396
f.write("}\n\n")
407397

408398
def emit_grapheme_module(f, grapheme_table, grapheme_cats):

src/libcoretest/char.rs

-23
Original file line numberDiff line numberDiff line change
@@ -102,29 +102,6 @@ fn test_to_uppercase() {
102102
assert_eq!(upper('ᾀ'), ['Ἀ', 'Ι']);
103103
}
104104

105-
#[test]
106-
fn test_to_titlecase() {
107-
fn title(c: char) -> Vec<char> {
108-
c.to_titlecase().collect()
109-
}
110-
assert_eq!(title('a'), ['A']);
111-
assert_eq!(title('ö'), ['Ö']);
112-
assert_eq!(title('ß'), ['S', 's']); // not ẞ: Latin capital letter sharp s
113-
assert_eq!(title('ü'), ['Ü']);
114-
assert_eq!(title('💩'), ['💩']);
115-
116-
assert_eq!(title('σ'), ['Σ']);
117-
assert_eq!(title('τ'), ['Τ']);
118-
assert_eq!(title('ι'), ['Ι']);
119-
assert_eq!(title('γ'), ['Γ']);
120-
assert_eq!(title('μ'), ['Μ']);
121-
assert_eq!(title('α'), ['Α']);
122-
assert_eq!(title('ς'), ['Σ']);
123-
assert_eq!(title('DŽ'), ['Dž']);
124-
assert_eq!(title('fi'), ['F', 'i']);
125-
assert_eq!(title('ᾀ'), ['ᾈ']);
126-
}
127-
128105
#[test]
129106
fn test_is_control() {
130107
assert!('\u{0}'.is_control());

src/librustc_unicode/char.rs

-33
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,6 @@ impl Iterator for ToUppercase {
6767
fn next(&mut self) -> Option<char> { self.0.next() }
6868
}
6969

70-
/// An iterator over the titlecase mapping of a given character, returned from
71-
/// the [`to_titlecase` method](../primitive.char.html#method.to_titlecase) on
72-
/// characters.
73-
#[unstable(feature = "unicode", reason = "recently added")]
74-
pub struct ToTitlecase(CaseMappingIter);
75-
76-
#[stable(feature = "unicode_case_mapping", since = "1.2.0")]
77-
impl Iterator for ToTitlecase {
78-
type Item = char;
79-
fn next(&mut self) -> Option<char> { self.0.next() }
80-
}
81-
8270

8371
enum CaseMappingIter {
8472
Three(char, char, char),
@@ -477,27 +465,6 @@ impl char {
477465
ToLowercase(CaseMappingIter::new(conversions::to_lower(self)))
478466
}
479467

480-
/// Converts a character to its titlecase equivalent.
481-
///
482-
/// This performs complex unconditional mappings with no tailoring.
483-
/// See `to_uppercase()` for references and more information.
484-
///
485-
/// This differs from `to_uppercase()` since Unicode contains
486-
/// digraphs and ligature characters.
487-
/// For example, U+01F3 “dz” and U+FB01 “fi”
488-
/// map to U+01F1 “DZ” and U+0046 U+0069 “Fi”, respectively.
489-
///
490-
/// # Return value
491-
///
492-
/// Returns an iterator which yields the characters corresponding to the
493-
/// titlecase equivalent of the character. If no conversion is possible then
494-
/// an iterator with just the input character is returned.
495-
#[unstable(feature = "unicode", reason = "recently added")]
496-
#[inline]
497-
pub fn to_titlecase(self) -> ToTitlecase {
498-
ToTitlecase(CaseMappingIter::new(conversions::to_title(self)))
499-
}
500-
501468
/// Converts a character to its uppercase equivalent.
502469
///
503470
/// This performs complex unconditional mappings with no tailoring:

0 commit comments

Comments
 (0)