Skip to content

Rust:chars

springroll edited this page Dec 9, 2019 · 1 revision

chars()

Overview

chars関数は文字列をなめるイテレータ(Iterator<Item = char>)を生成する

Code

fn main() {
    let s = String::from("HogeFoo");
    println!("{:?}", s.chars()); // Chars(['H','o','g','e','F','o','o'])
    for ch in s.chars() {
        print!("{}", ch);        // HogeFoo
    }
}

Detail

Clone this wiki locally