about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src/llvm_util.rs
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2021-12-23 00:28:51 +0100
committerGitHub <noreply@github.com>2021-12-23 00:28:51 +0100
commit60625a6ef0ef57a2934918430be0121431ba96c9 (patch)
tree236d2a7b8fdf077588da4bc2a0eaa246e6c203f4 /compiler/rustc_codegen_llvm/src/llvm_util.rs
parent34926f0a1681458588a2d4240c0715ef9eff7d35 (diff)
parent417b6f354e98a3198f456223c97b162c30ab3a5e (diff)
downloadrust-60625a6ef0ef57a2934918430be0121431ba96c9.tar.gz
rust-60625a6ef0ef57a2934918430be0121431ba96c9.zip
Rollup merge of #88858 - spektom:to_lower_upper_rev, r=dtolnay
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
}
```
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/llvm_util.rs')
0 files changed, 0 insertions, 0 deletions