Skip to content

Remove char::to_titlecase. Fix #26555 #26561

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 25, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions src/etc/unicode.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,13 +372,6 @@ def emit_conversions_module(f, to_upper, to_lower, to_title):
}
}
pub fn to_title(c: char) -> [char; 3] {
match bsearch_case_table(c, to_titlecase_table) {
None => [c, '\\0', '\\0'],
Some(index) => to_titlecase_table[index].1
}
}
fn bsearch_case_table(c: char, table: &'static [(char, [char; 3])]) -> Option<usize> {
match table.binary_search_by(|&(key, _)| {
if c == key { Equal }
Expand All @@ -400,9 +393,6 @@ def emit_conversions_module(f, to_upper, to_lower, to_title):
emit_table(f, "to_uppercase_table",
sorted(to_upper.iteritems(), key=operator.itemgetter(0)),
is_pub=False, t_type = t_type, pfun=pfun)
emit_table(f, "to_titlecase_table",
sorted(to_title.iteritems(), key=operator.itemgetter(0)),
is_pub=False, t_type = t_type, pfun=pfun)
f.write("}\n\n")

def emit_grapheme_module(f, grapheme_table, grapheme_cats):
Expand Down
23 changes: 0 additions & 23 deletions src/libcoretest/char.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,29 +102,6 @@ fn test_to_uppercase() {
assert_eq!(upper('ᾀ'), ['Ἀ', 'Ι']);
}

#[test]
fn test_to_titlecase() {
fn title(c: char) -> Vec<char> {
c.to_titlecase().collect()
}
assert_eq!(title('a'), ['A']);
assert_eq!(title('ö'), ['Ö']);
assert_eq!(title('ß'), ['S', 's']); // not ẞ: Latin capital letter sharp s
assert_eq!(title('ü'), ['Ü']);
assert_eq!(title('💩'), ['💩']);

assert_eq!(title('σ'), ['Σ']);
assert_eq!(title('τ'), ['Τ']);
assert_eq!(title('ι'), ['Ι']);
assert_eq!(title('γ'), ['Γ']);
assert_eq!(title('μ'), ['Μ']);
assert_eq!(title('α'), ['Α']);
assert_eq!(title('ς'), ['Σ']);
assert_eq!(title('DŽ'), ['Dž']);
assert_eq!(title('fi'), ['F', 'i']);
assert_eq!(title('ᾀ'), ['ᾈ']);
}

#[test]
fn test_is_control() {
assert!('\u{0}'.is_control());
Expand Down
33 changes: 0 additions & 33 deletions src/librustc_unicode/char.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,6 @@ impl Iterator for ToUppercase {
fn next(&mut self) -> Option<char> { self.0.next() }
}

/// An iterator over the titlecase mapping of a given character, returned from
/// the [`to_titlecase` method](../primitive.char.html#method.to_titlecase) on
/// characters.
#[unstable(feature = "unicode", reason = "recently added")]
pub struct ToTitlecase(CaseMappingIter);

#[stable(feature = "unicode_case_mapping", since = "1.2.0")]
impl Iterator for ToTitlecase {
type Item = char;
fn next(&mut self) -> Option<char> { self.0.next() }
}


enum CaseMappingIter {
Three(char, char, char),
Expand Down Expand Up @@ -477,27 +465,6 @@ impl char {
ToLowercase(CaseMappingIter::new(conversions::to_lower(self)))
}

/// Converts a character to its titlecase equivalent.
///
/// This performs complex unconditional mappings with no tailoring.
/// See `to_uppercase()` for references and more information.
///
/// This differs from `to_uppercase()` since Unicode contains
/// digraphs and ligature characters.
/// For example, U+01F3 “dz” and U+FB01 “fi”
/// map to U+01F1 “DZ” and U+0046 U+0069 “Fi”, respectively.
///
/// # Return value
///
/// Returns an iterator which yields the characters corresponding to the
/// titlecase equivalent of the character. If no conversion is possible then
/// an iterator with just the input character is returned.
#[unstable(feature = "unicode", reason = "recently added")]
#[inline]
pub fn to_titlecase(self) -> ToTitlecase {
ToTitlecase(CaseMappingIter::new(conversions::to_title(self)))
}

/// Converts a character to its uppercase equivalent.
///
/// This performs complex unconditional mappings with no tailoring:
Expand Down
Loading