Is there a good reason why String has no `into_chars`

Note that you can implement this iterator without having to do anything nasty:

struct IntoChars {
    string: String,
    position: usize,
}

impl Iterator for IntoChars {
    type Item = char;

    fn next(&mut self) -> Option<char> {
        let c = self.string[self.position..].chars().next()?;
        self.position += c.len_utf8();
        Some(c)
    }
}

An into_chars method for String still sounds reasonable though.

Edit: @quaternic you beat me by about a second.

4 Likes