Skip to content
Closed
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
9 changes: 2 additions & 7 deletions library/alloc/src/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,16 +385,11 @@ impl str {
map_uppercase_sigma(rest, i, &mut s)
} else {
match conversions::to_lower(c) {
[a, '\0', _] => s.push(a),
[a, b, '\0'] => {
[a, '\0'] => s.push(a),
[a, b] => {
s.push(a);
s.push(b);
}
[a, b, c] => {
s.push(a);
s.push(b);
s.push(c);
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/char/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,7 @@ impl char {
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn to_lowercase(self) -> ToLowercase {
ToLowercase(CaseMappingIter::new(conversions::to_lower(self)))
ToLowercase(CaseMappingIter::new_lower(conversions::to_lower(self)))
}

/// Returns an iterator that yields the uppercase mapping of this `char` as one or more
Expand Down
7 changes: 7 additions & 0 deletions library/core/src/char/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,13 @@ impl CaseMappingIter {
CaseMappingIter::Three(chars[0], chars[1], chars[2])
}
}
fn new_lower(chars: [char; 2]) -> CaseMappingIter {
if chars[1] == '\0' {
CaseMappingIter::One(chars[0]) // Including if chars[0] == '\0'
} else {
CaseMappingIter::Two(chars[0], chars[1])
}
}
}

impl Iterator for CaseMappingIter {
Expand Down
Loading