Skip to main content

bisect

Function bisect 

Source
pub fn bisect<T: Bisect, E: From<GeopError>>(
    lo: T,
    hi: T,
    steps: usize,
    until_collapsed: bool,
    side: impl FnMut(T) -> Result<Option<bool>, E>,
) -> Result<Bracket<T>, E>
Expand description

Bisects (lo, hi) at most steps times. side(mid) says whether the middle lies on lo’s side (Some(true), it becomes lo), on hi’s (Some(false)), or cannot be told (None, which stops the bisection). With until_collapsed, it also stops once the middle no longer lies strictly inside the bracket. side may keep state of its own — a seed carried from one middle to the next — since every step asks it once.