How to judge if a value is in the vec?


#1

For example:

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

How to know if a in v or not?


#2

v.contains(&a)


#3

Sorry, but no method named contians for vec?


#4

It’s in slice: https://doc.rust-lang.org/std/primitive.slice.html#method.contains

A Vec automatically coerces to a slice when needed.