Skip to content

Rust:count

springroll edited this page Dec 9, 2019 · 1 revision

count()

Overview

イテレータのメソッドcount関数はイテレータの数を数える

Code

fn main() {
    let v = vec![1, 2, 3];
    println!("{}", v.iter().count());  // 3

    let s = String::from("hoge");
    println!("{}", s.chars().count()); // 4
}

Detail

Clone this wiki locally