What is Vec?

It means “Rust compiler, infer what type goes into the Vec“. And it is indeed analogous to the unused variable in Python (and in Rust itself), in that it represents a placeholder for a type, like it can represent a placeholder for a variable name.

You can find an explanation in The Rust Programming Language chapter about iterator consumers:

Using a _ will let you provide a partial hint:

let one_to_one_hundred = (1..101).collect::<Vec<_>>(); This says
“Collect into a Vec<T>, please, but infer what the T is for me.” _ is
sometimes called a “type placeholder” for this reason.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)