Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting strings to lowercase

How does one convert a string to a lowercase or perform some kind of equivalency comparison ignoring case? There is an ignore case on the Ascii type but it seems convoluted and I don't see a way to convert str to Ascii.

like image 628
Daniel Fath Avatar asked Feb 27 '26 09:02

Daniel Fath


1 Answers

std::ascii::AsciiExt.eq_ignore_ascii_case does what you want:

use std::ascii::AsciiExt;

fn main() {
    assert!("foo".eq_ignore_ascii_case("FOO"));
}

(The search in the docs is quite good now; searches like "case" and "ascii" return good sets of results which contain this solution.)

like image 200
Chris Morgan Avatar answered Mar 02 '26 06:03

Chris Morgan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!