Description
Location
Local docs from rustup under /std/primitive.slice.html#method.binary_search
also for VecDeque
and the other binary search functions (search_by
)
Summary
There is written https://doc.rust-lang.org/nightly/std/primitive.slice.html#method.binary_search
Binary searches this slice for a given element. This behaves similarly to contains if this slice is sorted.
To me this first sounded like the binary search would work on all the slices and if it would be sorted sth would be different. Some people told me that it won't work if the slice isn't sorted and it will just output garbage.
If this really is the case it should be written that it only works for sorted slices (and VecDeque
s).
In any case the different behaviors when sorted and unsorted should be clarified
(e.g. if linear search is done on unsorted slice)