# VecDeque: binary search fns

**URL:** <https://internals.rust-lang.org/t/vecdeque-binary-search-fns/13132>\
**Category:** Uncategorized\
**Created:** [September 25, 2020, 8:45pm UTC](https://internals.rust-lang.org/t/vecdeque-binary-search-fns/13132 "2020-09-25T20:45:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vojtechkral](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/vojtechkral/32/605_2.png) [@vojtechkral](https://internals.rust-lang.org/u/vojtechkral)\
**Post date:** [September 25, 2020, 8:45pm UTC](https://internals.rust-lang.org/t/vecdeque-binary-search-fns/13132/1 "2020-09-25T20:45:41Z")

</div>

Today I had to write an extension trait for `VecDeque` adding the binary search functions that slice (and via deref `Vec`) has (`binary_search()` et al.).

Would that be worthy of adding to the stdlib?

---

<div class="post-metadata">

**Author:** ![scottmcm](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/scottmcm/32/2355_2.png) [@scottmcm](https://internals.rust-lang.org/u/scottmcm)\
**Post date:** [September 25, 2020, 9:10pm UTC](https://internals.rust-lang.org/t/vecdeque-binary-search-fns/13132/2 "2020-09-25T21:10:51Z")

</div>

I think it sounds reasonable. Should be able to do it on `VecDeque::as_slices` so it does one comparison then delegates to the slice version.

---

<div class="post-metadata">

**Author:** ![vojtechkral](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/vojtechkral/32/605_2.png) [@vojtechkral](https://internals.rust-lang.org/u/vojtechkral)\
**Post date:** [September 26, 2020, 8:39pm UTC](https://internals.rust-lang.org/t/vecdeque-binary-search-fns/13132/3 "2020-09-26T20:39:32Z")

</div>

> [@scottmcm](#):
>
> Should be able to do it on `VecDeque::as_slices` so it does one comparison then delegates to the slice version.

Yeah, that's exactly how my extension works currently 🙂

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/system/32/14092_2.png) [@system](https://internals.rust-lang.org/u/system)\
**Post date:** [December 25, 2020, 8:39pm UTC](https://internals.rust-lang.org/t/vecdeque-binary-search-fns/13132/4 "2020-12-25T20:39:34Z")

</div>

Closed on December 25, 2020, 8:39pm UTC

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
