-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rust "binary_search" return type -> choose uszie or i32 ? #479
Comments
@sjinzh @xBLACKICEx |
Simplicity is one of the principles of this book. This looks like a language syntax sugar that doesn't suppress the
Using |
The code use of In Rust, array indices must be of non-negative integer type Of course, my programming level is not high, and my analysis may not be accurate. Of course, you are not wrong that data structures and algorithms are indeed largely language-independent, but in my view, there is a problem with this code. If you do not think so, you can ignore this. #[test]
fn test_binary_search() {
let nums = [2, 3, 4, 7, 9];
assert_eq!(-1, BinarySearch::binary_search_i(&nums, 1));
} |
It is designed to return |
@night-cruise Could you please track the issue, thanks! |
I think the binary search in Rust could be written like this:
This is more in line with Rust's language features, maybe
The text was updated successfully, but these errors were encountered: