Crate partition_point[][src]

Expand description

Computes the index of the partition point.

Examples

use partition_point::RangeBoundsExt as _;

assert_eq!(1000, (0..1 << 30).partition_point(|n| n.to_string().len() <= 3));
assert_eq!(100, (0..100).partition_point(|_| true));
use partition_point::SliceExt as _;

assert_eq!(5, [0,    0,    0,    0,    0,    1,    1].partition_point(|&x| x == 0));
//             ^     ^     ^     ^     ^     ^     ^
//  index:     0     1     2     3     4     5     6
//  predicate: true  true  true  true  true  false false

assert_eq!(7, [(),   (),   (),   (),   (),   (),   ()].partition_point(|_| true));
//             ^     ^     ^     ^     ^     ^     ^
//  index:     0     1     2     3     4     5     6
//  predicate: true  true  true  true  true  true  true

Traits

PrimitiveInteger
RangeBoundsExt
SliceExt