std-method

Iterator::product

Multiply numeric items using the chosen Product implementation. The empty integer product is one, and integer overflow still needs consideration. Expected stdout (not executed): 24 Common mistake: Starting a manual product accumulator at zero.

Formal Syntax & Structure

rust syntaxrust
fn product<P: Product<Self::Item>>(self) -> P where Self: Sized

Working Example

Example Snippetrust
fn main() {    let choices: u32 = [2, 3, 4].into_iter().product();    println!("{choices}");}
Rust Reference