std-method

slice::contains

Check whether an element compares equal to the requested value. The scan does not require sorted input. Expected stdout (not executed): true false Common mistake: Assuming contains returns the matching position.

Formal Syntax & Structure

rust syntaxrust
slice.contains(&value) -> bool

Working Example

Example Snippetrust
fn main() {    let codes = [200, 404, 500];    println!("{} {}", codes.contains(&404), codes.contains(&403));}
Rust Reference