Skip to main content

Rust Cheat Sheet

Array​

Maximum/minimum value​

let max = array.iter().max().unwrap();
let min = array.iter().min().unwrap();

str, String​

prefix matching​

assert!("hello, world!".ends_with("h"));
assert!("hello, world!".ends_with("hello"));

suffix matching​

assert!("hello, world!".ends_with("!"));
assert!("hello, world!".ends_with("world!"));