MCPcopy Create free account
hub / github.com/Apress/beginning-rust-2e / min

Function min

Source Code/15-12.rs:4–11  ·  view source on GitHub ↗
(arr: &[i32])

Source from the content-addressed store, hash-verified

217 22*/
3fn main() {
4 fn min(arr: &[i32]) -> i32 {
5 // Let's assume 'arr' is not empty.
6 let mut minimum = arr[0];
7 for i in 1..arr.len() {
8 if arr[i] < minimum { minimum = arr[i]; }
9 }
10 minimum
11 }
12 print!("{} ", min(&[23, 17]));
13 print!("{}", min(&vec![55, 22, 33, 44]));
14}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected