mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-29 10:13:54 +00:00
60625a6ef0
Allow reverse iteration of lowercase'd/uppercase'd chars The PR implements `DoubleEndedIterator` trait for `ToLowercase` and `ToUppercase`. This enables reverse iteration of lowercase/uppercase variants of character sequences. One of use cases: determining whether a char sequence is a suffix of another one. Example: ```rust fn endswith_ignore_case(s1: &str, s2: &str) -> bool { for eob in s1 .chars() .flat_map(|c| c.to_lowercase()) .rev() .zip_longest(s2.chars().flat_map(|c| c.to_lowercase()).rev()) { match eob { EitherOrBoth::Both(c1, c2) => { if c1 != c2 { return false; } } EitherOrBoth::Left(_) => return true, EitherOrBoth::Right(_) => return false, } } true } ``` |
||
---|---|---|
.. | ||
arc.rs | ||
binary_heap.rs | ||
borrow.rs | ||
boxed.rs | ||
btree_set_hash.rs | ||
const_fns.rs | ||
cow_str.rs | ||
fmt.rs | ||
heap.rs | ||
lib.rs | ||
linked_list.rs | ||
rc.rs | ||
slice.rs | ||
str.rs | ||
string.rs | ||
vec_deque.rs | ||
vec.rs |