fn update_bound<P: Fn(&OF, &OF) -> bool>(
        existing_bound: &mut Option<OF>,
        new: &OF,
        is_better: P,
    ) -> Option<Option<OF>> {
        match existing_bound {
            Some(existing) => {
                if is_better(new, existing) {
                    let difference = new - &*existing;
                    *existing = new.clone();
                    Some(Some(difference))
                } else {
                    None
                }
            }
            None => {
                *existing_bound = Some(new.clone());
                Some(None)
            }
        }
    }
/// Update either the lower or upper bound, if it makes the bound tighter.
///
/// This is a helper method.
///
/// # Arguments
///
/// * `existing_bound`: Bound that could be updated.
/// * `new`: New bound value.
/// * `is_better`: A predicate indicating whether the new bound is better than the old bound, or
/// not.
///
/// # Return value
///
/// `None` if the bound was not updated, `Some` if it was. If there was no bound before, a
/// `None`, otherwise, a `Some` with the difference between the old and new bound.
Update either the lower or upper bound, if it makes the bound tighter.
This is a helper method.
Update either the lower or upper bound if it makes the bound tighter . This is a helper method .
fn update_bound<P: Fn(&OF, &OF) -> bool>(
        existing_bound: &mut Option<OF>,
        new: &OF,
        is_better: P,
    ) -> Option<Option<OF>> {
        match existing_bound {
            Some(existing) => {
                if is_better(new, existing) {
                    let difference = new - &*existing;
                    *existing = new.clone();
                    Some(Some(difference))
                } else {
                    None
                }
            }
            None => {
                *existing_bound = Some(new.clone());
                Some(None)
            }
        }
    }
fn update_bound < P : Fn ( & OF , & OF ) -> bool > ( existing_bound : & mut Option < OF > , new : & OF , is_better : P , ) -> Option < Option < OF > > { match existing_bound { Some ( existing ) => { if is_better ( new , existing ) { let difference = new - & * existing ; * existing = new . clone ( ) ; Some ( Some ( difference ) ) } else { None } } None => { * existing_bound = Some ( new . clone ( ) ) ; Some ( None ) } } }
Update either the lower or upper bound, if it makes the bound tighter.
Update either the lower or upper bound if it makes the bound tighter .
existing_bound
&mut Option<OF>
new
&OF
is_better
P
existing_bound
&mut Option<OF>
new
&OF
is_better
P
return value
`None` if the bound was not updated, `Some` if it was. If there was no bound before, a
`None`, otherwise, a `Some` with the difference between the old and new bound.
` None ` if the bound was not updated ` Some ` if it was . If there was no bound before a ` None ` otherwise a ` Some ` with the difference between the old and new bound .