#array #range #bisect #slice #bisectable #bisect-right #bisect-left

bifurcate

A general, extensible and performant implementation of bisect

1 unstable release

0.1.0 Oct 1, 2024

#2013 in Rust patterns

MIT license

59KB
610 lines

Bifurcate (WIP)

A small lib that adds a generalized binary search implementation which can be implemented for several types.


lib.rs:

Bifurcate

This is a small crate with the only purpose to provide and efficient and really general implementation of bisect_left, bisect_right and equal_range for some obvious types, while also giving the possibility of other types using the implementation.

The main trait, Bisectable, is implemented for Range, slice and array as a convenience. Also, the slice implementation can serve as a simple implementation blueprint for other types.

Note

This crate polyfills the Step trait, as it's unstable see #42168. This can be disabled via the nightly_step feature flag.

Related to the above, there's the nightly_ascii feature flag, which enables the implementation for Step for the nightly only AsciiChar, see #110998, which also implements the nightly only trait Step.

No runtime deps

Features