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

Function min

Source Code/15-10.rs:4–12  ·  view source on GitHub ↗
(arr: &[i32; 8], start: usize, count: usize)

Source from the content-addressed store, hash-verified

215*/
3fn main() {
4 fn min(arr: &[i32; 8], start: usize, count: usize) -> i32 {
5 // Let's assume 'start' is between 0 and 7,
6 // and 'count' is between 1 and 8 - start.
7 let mut minimum = arr[start];
8 for i in start + 1..start + count {
9 if arr[i] < minimum { minimum = arr[i]; }
10 }
11 minimum
12 }
13 print!("{}", min(&[23, 17, 12, 16, 15, 28, 17, 30], 3, 2));
14}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected