How to judge if a value is in the vec?

For example:

let a : i32 = 1;
let v :i32 = vec![1,2,3];

How to know if a in v or not?

v.contains(&a)

Sorry, but no method named contians for vec?

It's in slice: slice - Rust

A Vec automatically coerces to a slice when needed.

2 Likes