pub fn add_bucket(new_bound: f64, mut buckets: Vec<f64>) -> Vec<f64> {
    // core::cmp::Ord is not implemented for f64, so we rely on the partial
    // ordering. Total ordering has to deal with NaNs, +/-Infs, which we don't
    // have do to here, simply because such values will cause Prometheus to
    // throw errors.
    match buckets.binary_search_by(|probe| probe.partial_cmp(&new_bound).unwrap_or(Ordering::Less))
    {
        Ok(_) => {} // element already in vector @ `pos`
        Err(pos) => buckets.insert(pos, new_bound),
    }
    buckets
}
/// Insert a bucket in the existing vector of buckets.
///
/// The bucket will be added in the correct order in the vector. The method
/// assumes that the elements of the bucket are already sorted.
///
/// # Examples
///
/// ```
/// use ic_metrics::buckets::{add_bucket, decimal_buckets};
/// assert_eq!(vec![1.0, 2.0, 4.5, 5.0], add_bucket(4.5, decimal_buckets(0, 0)));
/// ```
Insert a bucket in the existing vector of buckets.
The bucket will be added in the correct order in the vector. The method
assumes that the elements of the bucket are already sorted.
Insert a bucket in the existing vector of buckets . The bucket will be added in the correct order in the vector . The method assumes that the elements of the bucket are already sorted .
pub fn add_bucket(new_bound: f64, mut buckets: Vec<f64>) -> Vec<f64> {
    // core::cmp::Ord is not implemented for f64, so we rely on the partial
    // ordering. Total ordering has to deal with NaNs, +/-Infs, which we don't
    // have do to here, simply because such values will cause Prometheus to
    // throw errors.
    match buckets.binary_search_by(|probe| probe.partial_cmp(&new_bound).unwrap_or(Ordering::Less))
    {
        Ok(_) => {} // element already in vector @ `pos`
        Err(pos) => buckets.insert(pos, new_bound),
    }
    buckets
}
pub fn add_bucket ( new_bound : f64 , mut buckets : Vec < f64 > ) -> Vec < f64 > { // core::cmp::Ord is not implemented for f64, so we rely on the partial // ordering. Total ordering has to deal with NaNs, +/-Infs, which we don't // have do to here, simply because such values will cause Prometheus to // throw errors. match buckets . binary_search_by ( | probe | probe . partial_cmp ( & new_bound ) . unwrap_or ( Ordering :: Less ) ) { Ok ( _ ) => { } // element already in vector @ `pos` Err ( pos ) => buckets . insert ( pos , new_bound ) , } buckets }
Insert a bucket in the existing vector of buckets.
Insert a bucket in the existing vector of buckets .
new_bound
f64
buckets
Vec<f64>
new_bound
f64
buckets
Vec<f64>
examples
None