()
| 21 | } |
| 22 | |
| 23 | fn 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 | } |
nothing calls this directly
no outgoing calls
no test coverage detected