MCPcopy Create free account
hub / github.com/IntegralPilot/rustc_codegen_jvm / main

Function main

tests/binary/binsearch/src/main.rs:23–36  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

21}
22
23fn main() {
24 // demo array (must be sorted!)
25 let arr = [1, 2, 3, 5, 8, 13, 21];
26
27 // successful searches
28 assert!(binary_search(&arr, 1) == Some(0));
29 assert!(binary_search(&arr, 5) == Some(3));
30 assert!(binary_search(&arr, 21) == Some(6));
31
32 // unsuccessful searches
33 assert!(binary_search(&arr, 0).is_none());
34 assert!(binary_search(&arr, 4).is_none());
35 assert!(binary_search(&arr, 22).is_none());
36}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected