histogram/
bucket.rs

1use core::ops::RangeInclusive;
2
3/// A bucket represents a quantized range of values and a count of observations
4/// that fall into that range.
5#[derive(Clone, Debug, PartialEq)]
6pub struct Bucket {
7    pub(crate) count: u64,
8    pub(crate) range: RangeInclusive<u64>,
9}
10
11impl Bucket {
12    /// Returns the number of observations within the bucket's range.
13    pub fn count(&self) -> u64 {
14        self.count
15    }
16
17    /// Returns the range for the bucket.
18    pub fn range(&self) -> RangeInclusive<u64> {
19        self.range.clone()
20    }
21
22    /// Returns the inclusive lower bound for the bucket.
23    pub fn start(&self) -> u64 {
24        *self.range.start()
25    }
26
27    /// Returns the inclusive upper bound for the bucket.
28    pub fn end(&self) -> u64 {
29        *self.range.end()
30    }
31}