Skip to content

Commit

Permalink
refactor: delay get_middle invocation
Browse files Browse the repository at this point in the history
  • Loading branch information
rootulp committed Feb 12, 2025
1 parent f49501e commit 339ac51
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
4 changes: 2 additions & 2 deletions rust/binary-search/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ pub fn find(array: &[i32], key: i32) -> Option<usize> {
if array.is_empty() {
return None
}

let mut left = 0;
let mut right = array.len() - 1;
let mut middle = get_middle(left, right);
println!("left: {}, right: {}, middle: {}", left, right, middle);
let mut middle;

while left <= right {
middle = get_middle(left, right);
Expand Down
1 change: 0 additions & 1 deletion rust/binary-search/tests/binary-search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ fn nothing_is_found_in_an_empty_array() {
}

#[test]
#[ignore]
fn nothing_is_found_when_the_left_and_right_bounds_cross() {
assert_eq!(find(&[1, 2], 0), None);
}
Expand Down

0 comments on commit 339ac51

Please sign in to comment.