Skip to content

Commit 339ac51

Browse files
committed
refactor: delay get_middle invocation
1 parent f49501e commit 339ac51

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

rust/binary-search/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ pub fn find(array: &[i32], key: i32) -> Option<usize> {
22
if array.is_empty() {
33
return None
44
}
5+
56
let mut left = 0;
67
let mut right = array.len() - 1;
7-
let mut middle = get_middle(left, right);
8-
println!("left: {}, right: {}, middle: {}", left, right, middle);
8+
let mut middle;
99

1010
while left <= right {
1111
middle = get_middle(left, right);

rust/binary-search/tests/binary-search.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ fn nothing_is_found_in_an_empty_array() {
5757
}
5858

5959
#[test]
60-
#[ignore]
6160
fn nothing_is_found_when_the_left_and_right_bounds_cross() {
6261
assert_eq!(find(&[1, 2], 0), None);
6362
}

0 commit comments

Comments
 (0)