String.into_ascii_lowercase


#1

When using format! it would be convenient to be able to into_ascii_lowercase(self) -> String

The implementation is simple:

fn into_ascii_lowercase(self) -> String {
    self.make_ascii_lowercase();
    self
}

Because this is what my code looks like, and not having into_ascii_lowercase makes it rather painful: (but maybe the compiler can optimize the allocation out)

impl std::fmt::Display for AudioFormat {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        match *self {
            default @ _ => write!(f, "{}", format!("{:?}", default).to_ascii_lowercase()),
        }
    }
}

(as seen in mpv-audio crate.)


#2

That would be nice indeed.

BTW, there’s f.write_str() instead of write!(f, "{}").