| 1 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::collectionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/::BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#; |
| 2 | |
| 3 | use craterust-analyzer cargo histogram 1.5.0 crate/::quantilerust-analyzer cargo histogram 1.5.0 quantile/::{Quantilerust-analyzer cargo histogram 1.5.0 quantile/Quantile#, QuantilesResultrust-analyzer cargo histogram 1.5.0 quantile/QuantilesResult#, SampleQuantilesrust-analyzer cargo histogram 1.5.0 quantile/SampleQuantiles#}; |
| 4 | use craterust-analyzer cargo histogram 1.5.0 crate/::{Bucketrust-analyzer cargo histogram 1.5.0 bucket/Bucket#, Configrust-analyzer cargo histogram 1.5.0 config/Config#, Countrust-analyzer cargo histogram 1.5.0 count/Count#, Errorrust-analyzer cargo histogram 1.5.0 errors/Error#, SparseHistogramrust-analyzer cargo histogram 1.5.0 sparse/SparseHistogram#, SparseHistogram32rust-analyzer cargo histogram 1.5.0 sparse/SparseHistogram32#}; |
| 5 | |
| 6 | macro_rules! define_histogramrust-analyzer cargo histogram 1.5.0 standard/define_histogram! { |
| 7 | ($name:ident, $iter:ident, $sparse:ident, $count:ty) => { |
| 8 | /// A histogram that uses plain counters for each bucket. |
| 9 | #[derive(Clone, Debug, PartialEq, Eq)] |
| 10 | #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] |
| 11 | #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] |
| 12 | pub struct $name { |
| 13 | pub(crate) config: Config, |
| 14 | pub(crate) buckets: Box<[$count]>, |
| 15 | } |
| 16 | |
| 17 | impl $name { |
| 18 | /// Construct a new histogram from the provided parameters. |
| 19 | pub fn new(grouping_power: u8, max_value_power: u8) -> Result<Self, Error> { |
| 20 | let config = Config::new(grouping_power, max_value_power)?; |
| 21 | Ok(Self::with_config(&config)) |
| 22 | } |
| 23 | |
| 24 | /// Creates a new histogram using a provided [`crate::Config`]. |
| 25 | pub fn with_config(config: &Config) -> Self { |
| 26 | let buckets: Box<[$count]> = |
| 27 | vec![<$count as Count>::ZERO; config.total_buckets()].into(); |
| 28 | Self { |
| 29 | config: *config, |
| 30 | buckets, |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | /// Creates a new histogram from a config and a vector of buckets. |
| 35 | pub fn from_buckets( |
| 36 | grouping_power: u8, |
| 37 | max_value_power: u8, |
| 38 | buckets: Vec<$count>, |
| 39 | ) -> Result<Self, Error> { |
| 40 | let config = Config::new(grouping_power, max_value_power)?; |
| 41 | if config.total_buckets() != buckets.len() { |
| 42 | return Err(Error::IncompatibleParameters); |
| 43 | } |
| 44 | Ok(Self { |
| 45 | config, |
| 46 | buckets: buckets.into(), |
| 47 | }) |
| 48 | } |
| 49 | |
| 50 | /// Increment the counter for the bucket corresponding to `value` by one. |
| 51 | /// Uses wrapping arithmetic on overflow. |
| 52 | pub fn increment(&mut self, value: u64) -> Result<(), Error> { |
| 53 | self.add(value, <$count as Count>::ONE) |
| 54 | } |
| 55 | |
| 56 | /// Add `count` to the bucket containing `value`. Uses wrapping |
| 57 | /// arithmetic on overflow. |
| 58 | pub fn add(&mut self, value: u64, count: $count) -> Result<(), Error> { |
| 59 | let index = self.config.value_to_index(value)?; |
| 60 | self.buckets[index] = self.buckets[index].wrapping_add(count); |
| 61 | Ok(()) |
| 62 | } |
| 63 | |
| 64 | /// Get a reference to the raw counters. |
| 65 | pub fn as_slice(&self) -> &[$count] { |
| 66 | &self.buckets |
| 67 | } |
| 68 | |
| 69 | /// Get a mutable reference to the raw counters. |
| 70 | pub fn as_mut_slice(&mut self) -> &mut [$count] { |
| 71 | &mut self.buckets |
| 72 | } |
| 73 | |
| 74 | /// Returns a new histogram with a reduced grouping power. The reduced |
| 75 | /// grouping power should lie in the range (0..existing grouping power). |
| 76 | /// |
| 77 | /// Returns an error if the requested grouping power is not less than the current grouping power. |
| 78 | /// |
| 79 | /// The difference in grouping powers determines how much histogram size |
| 80 | /// is reduced by, with every step approximately halving the total |
| 81 | /// number of buckets (and hence total size of the histogram), while |
| 82 | /// doubling the relative error. |
| 83 | /// |
| 84 | /// This works by iterating over every bucket in the existing histogram |
| 85 | /// and inserting the contained values into the new histogram. While we |
| 86 | /// do not know the exact values of the data points (only that they lie |
| 87 | /// within the bucket's range), it does not matter since the bucket is |
| 88 | /// not split during downsampling and any value can be used. |
| 89 | pub fn downsample(&self, grouping_power: u8) -> Result<Self, Error> { |
| 90 | if grouping_power >= self.config.grouping_power() { |
| 91 | return Err(Error::IncompatibleParameters); |
| 92 | } |
| 93 | let mut histogram = Self::new(grouping_power, self.config.max_value_power())?; |
| 94 | for (i, n) in self.as_slice().iter().enumerate() { |
| 95 | if *n != <$count as Count>::ZERO { |
| 96 | let val = self.config.index_to_lower_bound(i); |
| 97 | histogram.add(val, *n)?; |
| 98 | } |
| 99 | } |
| 100 | Ok(histogram) |
| 101 | } |
| 102 | |
| 103 | /// Adds the other histogram to this histogram and returns the result as a |
| 104 | /// new histogram. |
| 105 | /// |
| 106 | /// An error is returned if the two histograms have incompatible parameters |
| 107 | /// or if there is an overflow. |
| 108 | pub fn checked_add(&self, other: &Self) -> Result<Self, Error> { |
| 109 | if self.config != other.config { |
| 110 | return Err(Error::IncompatibleParameters); |
| 111 | } |
| 112 | let mut result = self.clone(); |
| 113 | for (this, other) in result.buckets.iter_mut().zip(other.buckets.iter()) { |
| 114 | *this = this.checked_add(*other).ok_or(Error::Overflow)?; |
| 115 | } |
| 116 | Ok(result) |
| 117 | } |
| 118 | |
| 119 | /// Adds the other histogram to this histogram and returns the result as a |
| 120 | /// new histogram. |
| 121 | /// |
| 122 | /// An error is returned if the two histograms have incompatible parameters. |
| 123 | pub fn wrapping_add(&self, other: &Self) -> Result<Self, Error> { |
| 124 | if self.config != other.config { |
| 125 | return Err(Error::IncompatibleParameters); |
| 126 | } |
| 127 | let mut result = self.clone(); |
| 128 | for (this, other) in result.buckets.iter_mut().zip(other.buckets.iter()) { |
| 129 | *this = this.wrapping_add(*other); |
| 130 | } |
| 131 | Ok(result) |
| 132 | } |
| 133 | |
| 134 | /// Subtracts the other histogram from this histogram and returns the result |
| 135 | /// as a new histogram. |
| 136 | /// |
| 137 | /// An error is returned if the two histograms have incompatible parameters |
| 138 | /// or if there is an overflow. |
| 139 | pub fn checked_sub(&self, other: &Self) -> Result<Self, Error> { |
| 140 | if self.config != other.config { |
| 141 | return Err(Error::IncompatibleParameters); |
| 142 | } |
| 143 | let mut result = self.clone(); |
| 144 | for (this, other) in result.buckets.iter_mut().zip(other.buckets.iter()) { |
| 145 | *this = this.checked_sub(*other).ok_or(Error::Underflow)?; |
| 146 | } |
| 147 | Ok(result) |
| 148 | } |
| 149 | |
| 150 | /// Subtracts the other histogram from this histogram and returns the result |
| 151 | /// as a new histogram. |
| 152 | /// |
| 153 | /// An error is returned if the two histograms have incompatible parameters. |
| 154 | pub fn wrapping_sub(&self, other: &Self) -> Result<Self, Error> { |
| 155 | if self.config != other.config { |
| 156 | return Err(Error::IncompatibleParameters); |
| 157 | } |
| 158 | let mut result = self.clone(); |
| 159 | for (this, other) in result.buckets.iter_mut().zip(other.buckets.iter()) { |
| 160 | *this = this.wrapping_sub(*other); |
| 161 | } |
| 162 | Ok(result) |
| 163 | } |
| 164 | |
| 165 | /// Returns an iterator across the histogram. |
| 166 | pub fn iter(&self) -> $iter<'_> { |
| 167 | $iter { |
| 168 | index: 0, |
| 169 | histogram: self, |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | /// Returns the bucket configuration of the histogram. |
| 174 | pub fn config(&self) -> Config { |
| 175 | self.config |
| 176 | } |
| 177 | |
| 178 | /// Compute quantiles for the given values. |
| 179 | /// |
| 180 | /// Each value in `quantiles` must be in `0.0..=1.0`. Returns |
| 181 | /// `Err(Error::InvalidQuantile)` if any value is out of range, |
| 182 | /// `Ok(None)` if the histogram is empty. |
| 183 | /// |
| 184 | /// This is an inherent forwarder for [`SampleQuantiles::quantiles`]. |
| 185 | pub fn quantiles(&self, quantiles: &[f64]) -> Result<Option<QuantilesResult>, Error> { |
| 186 | <Self as SampleQuantiles>::quantiles(self, quantiles) |
| 187 | } |
| 188 | |
| 189 | /// Compute a single quantile. |
| 190 | /// |
| 191 | /// The quantile must be in `0.0..=1.0`. Returns |
| 192 | /// `Err(Error::InvalidQuantile)` if out of range, `Ok(None)` if the |
| 193 | /// histogram is empty. |
| 194 | /// |
| 195 | /// This is an inherent forwarder for [`SampleQuantiles::quantile`]. |
| 196 | pub fn quantile(&self, quantile: f64) -> Result<Option<QuantilesResult>, Error> { |
| 197 | <Self as SampleQuantiles>::quantile(self, quantile) |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | impl SampleQuantiles for $name { |
| 202 | fn quantiles(&self, quantiles: &[f64]) -> Result<Option<QuantilesResult>, Error> { |
| 203 | for q in quantiles { |
| 204 | if !(0.0..=1.0).contains(q) { |
| 205 | return Err(Error::InvalidQuantile); |
| 206 | } |
| 207 | } |
| 208 | let total_count: u128 = self.buckets.iter().map(|v| v.as_u128()).sum(); |
| 209 | if total_count == 0 { |
| 210 | return Ok(None); |
| 211 | } |
| 212 | let mut sorted: Vec<Quantile> = quantiles |
| 213 | .iter() |
| 214 | .map(|&q| Quantile::new(q).unwrap()) |
| 215 | .collect(); |
| 216 | sorted.sort(); |
| 217 | sorted.dedup(); |
| 218 | |
| 219 | let mut min_idx = None; |
| 220 | let mut max_idx = None; |
| 221 | for (i, count) in self.buckets.iter().enumerate() { |
| 222 | if *count != <$count as Count>::ZERO { |
| 223 | if min_idx.is_none() { |
| 224 | min_idx = Some(i); |
| 225 | } |
| 226 | max_idx = Some(i); |
| 227 | } |
| 228 | } |
| 229 | let min_idx = min_idx.unwrap(); |
| 230 | let max_idx = max_idx.unwrap(); |
| 231 | |
| 232 | let min = Bucket { |
| 233 | count: self.buckets[min_idx].as_u128() as u64, |
| 234 | range: self.config.index_to_range(min_idx), |
| 235 | }; |
| 236 | let max = Bucket { |
| 237 | count: self.buckets[max_idx].as_u128() as u64, |
| 238 | range: self.config.index_to_range(max_idx), |
| 239 | }; |
| 240 | |
| 241 | let mut bucket_idx = 0; |
| 242 | let mut partial_sum = self.buckets[bucket_idx].as_u128(); |
| 243 | let mut entries = BTreeMap::new(); |
| 244 | |
| 245 | for quantile in &sorted { |
| 246 | let count = |
| 247 | std::cmp::max(1, (quantile.as_f64() * total_count as f64).ceil() as u128); |
| 248 | loop { |
| 249 | if partial_sum >= count { |
| 250 | entries.insert( |
| 251 | *quantile, |
| 252 | Bucket { |
| 253 | count: self.buckets[bucket_idx].as_u128() as u64, |
| 254 | range: self.config.index_to_range(bucket_idx), |
| 255 | }, |
| 256 | ); |
| 257 | break; |
| 258 | } |
| 259 | if bucket_idx == (self.buckets.len() - 1) { |
| 260 | break; |
| 261 | } |
| 262 | bucket_idx += 1; |
| 263 | partial_sum += self.buckets[bucket_idx].as_u128(); |
| 264 | } |
| 265 | } |
| 266 | |
| 267 | Ok(Some(QuantilesResult::new(entries, total_count, min, max))) |
| 268 | } |
| 269 | } |
| 270 | |
| 271 | impl<'a> IntoIterator for &'a $name { |
| 272 | type Item = Bucket; |
| 273 | type IntoIter = $iter<'a>; |
| 274 | fn into_iter(self) -> Self::IntoIter { |
| 275 | $iter { |
| 276 | index: 0, |
| 277 | histogram: self, |
| 278 | } |
| 279 | } |
| 280 | } |
| 281 | |
| 282 | /// An iterator across the histogram buckets. |
| 283 | pub struct $iter<'a> { |
| 284 | index: usize, |
| 285 | histogram: &'a $name, |
| 286 | } |
| 287 | |
| 288 | impl Iterator for $iter<'_> { |
| 289 | type Item = Bucket; |
| 290 | fn next(&mut self) -> Option<Bucket> { |
| 291 | if self.index >= self.histogram.buckets.len() { |
| 292 | return None; |
| 293 | } |
| 294 | let bucket = Bucket { |
| 295 | count: self.histogram.buckets[self.index].as_u128() as u64, |
| 296 | range: self.histogram.config.index_to_range(self.index), |
| 297 | }; |
| 298 | self.index += 1; |
| 299 | Some(bucket) |
| 300 | } |
| 301 | } |
| 302 | |
| 303 | impl ExactSizeIterator for $iter<'_> { |
| 304 | fn len(&self) -> usize { |
| 305 | self.histogram.buckets.len() - self.index |
| 306 | } |
| 307 | } |
| 308 | |
| 309 | impl std::iter::FusedIterator for $iter<'_> {} |
| 310 | |
| 311 | // Requires: `$sparse.count` is `Vec<$count>` (the same count type as `$name`). |
| 312 | // Task 4 enforces this when defining SparseHistogram32 alongside Histogram32. |
| 313 | impl From<&$sparse> for $name { |
| 314 | fn from(other: &$sparse) -> Self { |
| 315 | let mut histogram = $name::with_config(&other.config); |
| 316 | for (index, count) in other.index.iter().zip(other.count.iter()) { |
| 317 | histogram.buckets[*index as usize] = *count; |
| 318 | } |
| 319 | histogram |
| 320 | } |
| 321 | } |
| 322 | }; |
| 323 | } |
| 324 | |
| 325 | define_histogramrust-analyzer cargo histogram 1.5.0 standard/define_histogram!!(Histogramrust-analyzer cargo histogram 1.5.0 standard/Histogram#, Iterrust-analyzer cargo histogram 1.5.0 standard/Iter#, SparseHistogramrust-analyzer cargo histogram 1.5.0 sparse/SparseHistogram#, u64); |
| 326 | define_histogramrust-analyzer cargo histogram 1.5.0 standard/define_histogram!!(Histogram32rust-analyzer cargo histogram 1.5.0 standard/Histogram32#, Iter32rust-analyzer cargo histogram 1.5.0 standard/Iter32#, SparseHistogram32rust-analyzer cargo histogram 1.5.0 sparse/SparseHistogram32#, u32); |
| 327 | |
| 328 | // Deprecated forwarding methods — only on the u64 variant to avoid proliferating |
| 329 | // deprecated APIs onto the new u32 type. Mirrors the same pattern in sparse.rs. |
| 330 | impl Histogramrust-analyzer cargo histogram 1.5.0 standard/Histogram# { |
| 331 | /// Return a collection of percentiles from this histogram. |
| 332 | /// |
| 333 | /// Each percentile should be in the inclusive range `0.0..=1.0`. For |
| 334 | /// example, the 50th percentile (median) can be found using `0.5`. |
| 335 | /// |
| 336 | /// The results will be sorted by the percentile. |
| 337 | #[deprecated(note = "Use the SampleQuantiles trait")] |
| 338 | #[allow(deprecated)] |
| 339 | pub fn percentilesrust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram]percentiles().(&self, percentiles: &[f64]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<(f64, Bucketrust-analyzer cargo histogram 1.5.0 bucket/Bucket#)>>, Errorrust-analyzer cargo histogram 1.5.0 errors/Error#> { |
| 340 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(SampleQuantilesrust-analyzer cargo histogram 1.5.0 quantile/SampleQuantiles#::quantilesrust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram][SampleQuantiles]quantiles().(self, percentiles) |
| 341 | .map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|e| match e { |
| 342 | Errorrust-analyzer cargo histogram 1.5.0 errors/Error#::InvalidQuantilerust-analyzer cargo histogram 1.5.0 errors/Error#InvalidQuantile# => Errorrust-analyzer cargo histogram 1.5.0 errors/Error#::InvalidPercentilerust-analyzer cargo histogram 1.5.0 errors/Error#InvalidPercentile#, |
| 343 | other => other, |
| 344 | })?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). |
| 345 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|qr| { |
| 346 | qr.entriesrust-analyzer cargo histogram 1.5.0 quantile/impl#[QuantilesResult]entries().() |
| 347 | .iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]iter().() |
| 348 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|(q, b)| (q.as_f64rust-analyzer cargo histogram 1.5.0 quantile/impl#[Quantile]as_f64().(), b.clonerust-analyzer cargo histogram 1.5.0 bucket/impl#[Bucket][Clone]clone().())) |
| 349 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().() |
| 350 | })) |
| 351 | } |
| 352 | |
| 353 | /// Return a single percentile from this histogram. |
| 354 | /// |
| 355 | /// The percentile should be in the inclusive range `0.0..=1.0`. For |
| 356 | /// example, the 50th percentile (median) can be found using `0.5`. |
| 357 | #[deprecated(note = "Use the SampleQuantiles trait")] |
| 358 | pub fn percentilerust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram]percentile().(&self, percentile: f64) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Bucketrust-analyzer cargo histogram 1.5.0 bucket/Bucket#>, Errorrust-analyzer cargo histogram 1.5.0 errors/Error#> { |
| 359 | #[allow(deprecated)] |
| 360 | self.percentilesrust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram]percentiles().(&[percentile]) |
| 361 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map().(|v| v.maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|x| x.firstrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]first().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().1.clonerust-analyzer cargo histogram 1.5.0 bucket/impl#[Bucket][Clone]clone().())) |
| 362 | } |
| 363 | } |
| 364 | |
| 365 | #[cfg(test)] |
| 366 | mod testsrust-analyzer cargo histogram 1.5.0 standard/tests/ { |
| 367 | use superrust-analyzer cargo histogram 1.5.0 standard/::*; |
| 368 | use randrust-analyzer cargo rand 0.10.2 crate/::RngExtrust-analyzer cargo rand 0.10.2 rng/RngExt#; |
| 369 | |
| 370 | #[cfg(target_pointer_width = "64")] |
| 371 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 372 | fn sizerust-analyzer cargo histogram 1.5.0 standard/tests/size().() { |
| 373 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::size_ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/size_of().::<Histogramrust-analyzer cargo histogram 1.5.0 standard/Histogram#>(), 48); |
| 374 | } |
| 375 | |
| 376 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 377 | // Tests quantiles (replaces the deprecated percentile/percentiles tests). |
| 378 | fn quantilesrust-analyzer cargo histogram 1.5.0 standard/tests/quantiles().() { |
| 379 | let mut histogram = Histogramrust-analyzer cargo histogram 1.5.0 standard/Histogram#::newrust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram]new().(7, 64).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 380 | |
| 381 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(histogram.quantilerust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram]quantile().(0.5).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#); |
| 382 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(histogram.quantilesrust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram]quantiles().(&[0.5, 0.9, 0.99, 0.999]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#); |
| 383 | |
| 384 | for i in 0..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#100 { |
| 385 | let _ = histogram.incrementrust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram]increment().(i); |
| 386 | let r = histogram.quantilerust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram]quantile().(0.0).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 387 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 388 | r.getrust-analyzer cargo histogram 1.5.0 quantile/impl#[QuantilesResult]get().(&Quantilerust-analyzer cargo histogram 1.5.0 quantile/Quantile#::newrust-analyzer cargo histogram 1.5.0 quantile/impl#[Quantile]new().(0.0).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()), |
| 389 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&Bucketrust-analyzer cargo histogram 1.5.0 bucket/Bucket# { |
| 390 | countrust-analyzer cargo histogram 1.5.0 bucket/Bucket#count.: 1, |
| 391 | rangerust-analyzer cargo histogram 1.5.0 bucket/Bucket#range.: 0..=0, |
| 392 | }) |
| 393 | ); |
| 394 | let r = histogram.quantilerust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram]quantile().(1.0).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 395 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 396 | r.getrust-analyzer cargo histogram 1.5.0 quantile/impl#[QuantilesResult]get().(&Quantilerust-analyzer cargo histogram 1.5.0 quantile/Quantile#::newrust-analyzer cargo histogram 1.5.0 quantile/impl#[Quantile]new().(1.0).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()), |
| 397 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&Bucketrust-analyzer cargo histogram 1.5.0 bucket/Bucket# { |
| 398 | countrust-analyzer cargo histogram 1.5.0 bucket/Bucket#count.: 1, |
| 399 | rangerust-analyzer cargo histogram 1.5.0 bucket/Bucket#range.: i..=i, |
| 400 | }) |
| 401 | ); |
| 402 | } |
| 403 | let r = histogram.quantilerust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram]quantile().(0.0).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 404 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(r.getrust-analyzer cargo histogram 1.5.0 quantile/impl#[QuantilesResult]get().(&Quantilerust-analyzer cargo histogram 1.5.0 quantile/Quantile#::newrust-analyzer cargo histogram 1.5.0 quantile/impl#[Quantile]new().(0.0).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().endrust-analyzer cargo histogram 1.5.0 bucket/impl#[Bucket]end().(), 0); |
| 405 | let r = histogram.quantilerust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram]quantile().(0.25).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 406 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(r.getrust-analyzer cargo histogram 1.5.0 quantile/impl#[QuantilesResult]get().(&Quantilerust-analyzer cargo histogram 1.5.0 quantile/Quantile#::newrust-analyzer cargo histogram 1.5.0 quantile/impl#[Quantile]new().(0.25).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().endrust-analyzer cargo histogram 1.5.0 bucket/impl#[Bucket]end().(), 25); |
| 407 | let r = histogram.quantilerust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram]quantile().(0.50).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 408 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(r.getrust-analyzer cargo histogram 1.5.0 quantile/impl#[QuantilesResult]get().(&Quantilerust-analyzer cargo histogram 1.5.0 quantile/Quantile#::newrust-analyzer cargo histogram 1.5.0 quantile/impl#[Quantile]new().(0.50).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().endrust-analyzer cargo histogram 1.5.0 bucket/impl#[Bucket]end().(), 50); |
| 409 | let r = histogram.quantilerust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram]quantile().(0.75).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 410 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(r.getrust-analyzer cargo histogram 1.5.0 quantile/impl#[QuantilesResult]get().(&Quantilerust-analyzer cargo histogram 1.5.0 quantile/Quantile#::newrust-analyzer cargo histogram 1.5.0 quantile/impl#[Quantile]new().(0.75).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().endrust-analyzer cargo histogram 1.5.0 bucket/impl#[Bucket]end().(), 75); |
| 411 | let r = histogram.quantilerust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram]quantile().(0.90).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 412 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(r.getrust-analyzer cargo histogram 1.5.0 quantile/impl#[QuantilesResult]get().(&Quantilerust-analyzer cargo histogram 1.5.0 quantile/Quantile#::newrust-analyzer cargo histogram 1.5.0 quantile/impl#[Quantile]new().(0.90).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().endrust-analyzer cargo histogram 1.5.0 bucket/impl#[Bucket]end().(), 90); |
| 413 | let r = histogram.quantilerust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram]quantile().(0.99).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 414 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(r.getrust-analyzer cargo histogram 1.5.0 quantile/impl#[QuantilesResult]get().(&Quantilerust-analyzer cargo histogram 1.5.0 quantile/Quantile#::newrust-analyzer cargo histogram 1.5.0 quantile/impl#[Quantile]new().(0.99).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().endrust-analyzer cargo histogram 1.5.0 bucket/impl#[Bucket]end().(), 99); |
| 415 | let r = histogram.quantilerust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram]quantile().(0.999).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 416 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(r.getrust-analyzer cargo histogram 1.5.0 quantile/impl#[QuantilesResult]get().(&Quantilerust-analyzer cargo histogram 1.5.0 quantile/Quantile#::newrust-analyzer cargo histogram 1.5.0 quantile/impl#[Quantile]new().(0.999).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().endrust-analyzer cargo histogram 1.5.0 bucket/impl#[Bucket]end().(), 100); |
| 417 | |
| 418 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(histogram.quantilerust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram]quantile().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().1.0), Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo histogram 1.5.0 errors/Error#::InvalidQuantilerust-analyzer cargo histogram 1.5.0 errors/Error#InvalidQuantile#)); |
| 419 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(histogram.quantilerust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram]quantile().(1.01), Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo histogram 1.5.0 errors/Error#::InvalidQuantilerust-analyzer cargo histogram 1.5.0 errors/Error#InvalidQuantile#)); |
| 420 | |
| 421 | let _ = histogram.incrementrust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram]increment().(1024); |
| 422 | let r = histogram.quantilerust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram]quantile().(0.999).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 423 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 424 | r.getrust-analyzer cargo histogram 1.5.0 quantile/impl#[QuantilesResult]get().(&Quantilerust-analyzer cargo histogram 1.5.0 quantile/Quantile#::newrust-analyzer cargo histogram 1.5.0 quantile/impl#[Quantile]new().(0.999).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()), |
| 425 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&Bucketrust-analyzer cargo histogram 1.5.0 bucket/Bucket# { |
| 426 | countrust-analyzer cargo histogram 1.5.0 bucket/Bucket#count.: 1, |
| 427 | rangerust-analyzer cargo histogram 1.5.0 bucket/Bucket#range.: 1024..=1031, |
| 428 | }) |
| 429 | ); |
| 430 | } |
| 431 | |
| 432 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 433 | fn minrust-analyzer cargo histogram 1.5.0 standard/tests/min().() { |
| 434 | let mut histogram = Histogramrust-analyzer cargo histogram 1.5.0 standard/Histogram#::newrust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram]new().(7, 64).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 435 | |
| 436 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(histogram.quantilerust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram]quantile().(0.0).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#); |
| 437 | |
| 438 | let _ = histogram.incrementrust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram]increment().(10); |
| 439 | let r = histogram.quantilerust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram]quantile().(0.0).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 440 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(r.getrust-analyzer cargo histogram 1.5.0 quantile/impl#[QuantilesResult]get().(&Quantilerust-analyzer cargo histogram 1.5.0 quantile/Quantile#::newrust-analyzer cargo histogram 1.5.0 quantile/impl#[Quantile]new().(0.0).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().endrust-analyzer cargo histogram 1.5.0 bucket/impl#[Bucket]end().(), 10); |
| 441 | |
| 442 | let _ = histogram.incrementrust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram]increment().(4); |
| 443 | let r = histogram.quantilerust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram]quantile().(0.0).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 444 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(r.getrust-analyzer cargo histogram 1.5.0 quantile/impl#[QuantilesResult]get().(&Quantilerust-analyzer cargo histogram 1.5.0 quantile/Quantile#::newrust-analyzer cargo histogram 1.5.0 quantile/impl#[Quantile]new().(0.0).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().endrust-analyzer cargo histogram 1.5.0 bucket/impl#[Bucket]end().(), 4); |
| 445 | } |
| 446 | |
| 447 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 448 | fn downsamplerust-analyzer cargo histogram 1.5.0 standard/tests/downsample().() { |
| 449 | let mut histogram = Histogramrust-analyzer cargo histogram 1.5.0 standard/Histogram#::newrust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram]new().(8, 32).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 450 | let mut vals: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u64> = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::with_capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]with_capacity().(10000); |
| 451 | use randrust-analyzer cargo rand 0.10.2 crate/::SeedableRngrust-analyzer cargo rand_core 0.10.1 seedable_rng/SeedableRng#; |
| 452 | let mut rng = randrust-analyzer cargo rand 0.10.2 crate/::rngsrust-analyzer cargo rand 0.10.2 rngs/::SmallRngrust-analyzer cargo rand 0.10.2 rngs/small/SmallRng#::seed_from_u64rust-analyzer cargo rand 0.10.2 rngs/small/impl#[SmallRng][SeedableRng]seed_from_u64().(42); |
| 453 | |
| 454 | for _ in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#vals.capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]capacity().() { |
| 455 | let v: u64 = rng.random_rangerust-analyzer cargo rand 0.10.2 rng/RngExt#random_range().(1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#2_u64.powrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u64]pow().(histogram.configrust-analyzer cargo histogram 1.5.0 standard/Histogram#config..max_value_powerrust-analyzer cargo histogram 1.5.0 config/impl#[Config]max_value_power().() as u32)); |
| 456 | vals.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(v); |
| 457 | let _ = histogram.incrementrust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram]increment().(v); |
| 458 | } |
| 459 | vals.sortrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]sort().(); |
| 460 | |
| 461 | let mut percentiles: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<f64> = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::with_capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]with_capacity().(109); |
| 462 | for i in 20..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#99 { |
| 463 | percentiles.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(i as f64 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().100.0); |
| 464 | } |
| 465 | let mut tail = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 466 | 0.991, 0.992, 0.993, 0.994, 0.995, 0.996, 0.997, 0.998, 0.999, 0.9999, 1.0, |
| 467 | ]; |
| 468 | percentiles.appendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]append().(&mut tail); |
| 469 | |
| 470 | let h = histogram.clonerust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram][Clone]clone().(); |
| 471 | let grouping_power = histogram.configrust-analyzer cargo histogram 1.5.0 standard/Histogram#config..grouping_powerrust-analyzer cargo histogram 1.5.0 config/impl#[Config]grouping_power().(); |
| 472 | for factor in 1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#grouping_power { |
| 473 | let error = histogram.configrust-analyzer cargo histogram 1.5.0 standard/Histogram#config..errorrust-analyzer cargo histogram 1.5.0 config/impl#[Config]error().(); |
| 474 | |
| 475 | for p in &percentiles { |
| 476 | let v = vals[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().((*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().p rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().(vals.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() as f64)) as usize) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().1]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().; |
| 477 | let q = histogram.quantilerust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram]quantile().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().p).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 478 | let vhist = q.getrust-analyzer cargo histogram 1.5.0 quantile/impl#[QuantilesResult]get().(&Quantilerust-analyzer cargo histogram 1.5.0 quantile/Quantile#::newrust-analyzer cargo histogram 1.5.0 quantile/impl#[Quantile]new().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().p).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().endrust-analyzer cargo histogram 1.5.0 bucket/impl#[Bucket]end().(); |
| 479 | let e = (v.abs_diffrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u64]abs_diff().(vhist) as f64) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().100.0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().(v as f64); |
| 480 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(e <rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt(). error); |
| 481 | } |
| 482 | |
| 483 | histogram = h.downsamplerust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram]downsample().(grouping_power rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Sub<Self>`]sub().factor).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 484 | } |
| 485 | } |
| 486 | |
| 487 | fn build_histogramsrust-analyzer cargo histogram 1.5.0 standard/tests/build_histograms().() -> (Histogramrust-analyzer cargo histogram 1.5.0 standard/Histogram#, Histogramrust-analyzer cargo histogram 1.5.0 standard/Histogram#, Histogramrust-analyzer cargo histogram 1.5.0 standard/Histogram#, Histogramrust-analyzer cargo histogram 1.5.0 standard/Histogram#) { |
| 488 | let mut h1 = Histogramrust-analyzer cargo histogram 1.5.0 standard/Histogram#::newrust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram]new().(1, 3).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 489 | let mut h2 = Histogramrust-analyzer cargo histogram 1.5.0 standard/Histogram#::newrust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram]new().(1, 3).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 490 | let mut h3 = Histogramrust-analyzer cargo histogram 1.5.0 standard/Histogram#::newrust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram]new().(1, 3).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 491 | let h4 = Histogramrust-analyzer cargo histogram 1.5.0 standard/Histogram#::newrust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram]new().(7, 32).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 492 | |
| 493 | for i in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#h1.configrust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram]config().().total_bucketsrust-analyzer cargo histogram 1.5.0 config/impl#[Config]total_buckets().() { |
| 494 | h1.as_mut_slicerust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram]as_mut_slice().()[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().i]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). = 1; |
| 495 | h2.as_mut_slicerust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram]as_mut_slice().()[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().i]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). = 1; |
| 496 | h3.as_mut_slicerust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram]as_mut_slice().()[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().i]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). = u64::MAXrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u64]MAX.; |
| 497 | } |
| 498 | |
| 499 | (h1, h2, h3, h4) |
| 500 | } |
| 501 | |
| 502 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 503 | fn checked_addrust-analyzer cargo histogram 1.5.0 standard/tests/checked_add().() { |
| 504 | let (h, h_good, h_overflow, h_mismatch) = build_histogramsrust-analyzer cargo histogram 1.5.0 standard/tests/build_histograms().(); |
| 505 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 506 | h.checked_addrust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram]checked_add().(&h_mismatch), |
| 507 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo histogram 1.5.0 errors/Error#::IncompatibleParametersrust-analyzer cargo histogram 1.5.0 errors/Error#IncompatibleParameters#) |
| 508 | ); |
| 509 | let r = h.checked_addrust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram]checked_add().(&h_good).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 510 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(r.as_slicerust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram]as_slice().(), &[2, 2, 2, 2, 2, 2]); |
| 511 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(h.checked_addrust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram]checked_add().(&h_overflow), Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo histogram 1.5.0 errors/Error#::Overflowrust-analyzer cargo histogram 1.5.0 errors/Error#Overflow#)); |
| 512 | } |
| 513 | |
| 514 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 515 | fn wrapping_addrust-analyzer cargo histogram 1.5.0 standard/tests/wrapping_add().() { |
| 516 | let (h, h_good, h_overflow, h_mismatch) = build_histogramsrust-analyzer cargo histogram 1.5.0 standard/tests/build_histograms().(); |
| 517 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 518 | h.wrapping_addrust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram]wrapping_add().(&h_mismatch), |
| 519 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo histogram 1.5.0 errors/Error#::IncompatibleParametersrust-analyzer cargo histogram 1.5.0 errors/Error#IncompatibleParameters#) |
| 520 | ); |
| 521 | let r = h.wrapping_addrust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram]wrapping_add().(&h_good).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 522 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(r.as_slicerust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram]as_slice().(), &[2, 2, 2, 2, 2, 2]); |
| 523 | let r = h.wrapping_addrust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram]wrapping_add().(&h_overflow).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 524 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(r.as_slicerust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram]as_slice().(), &[0, 0, 0, 0, 0, 0]); |
| 525 | } |
| 526 | |
| 527 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 528 | fn checked_subrust-analyzer cargo histogram 1.5.0 standard/tests/checked_sub().() { |
| 529 | let (h, h_good, h_overflow, h_mismatch) = build_histogramsrust-analyzer cargo histogram 1.5.0 standard/tests/build_histograms().(); |
| 530 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 531 | h.checked_subrust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram]checked_sub().(&h_mismatch), |
| 532 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo histogram 1.5.0 errors/Error#::IncompatibleParametersrust-analyzer cargo histogram 1.5.0 errors/Error#IncompatibleParameters#) |
| 533 | ); |
| 534 | let r = h.checked_subrust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram]checked_sub().(&h_good).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 535 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(r.as_slicerust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram]as_slice().(), &[0, 0, 0, 0, 0, 0]); |
| 536 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(h.checked_subrust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram]checked_sub().(&h_overflow), Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo histogram 1.5.0 errors/Error#::Underflowrust-analyzer cargo histogram 1.5.0 errors/Error#Underflow#)); |
| 537 | } |
| 538 | |
| 539 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 540 | fn wrapping_subrust-analyzer cargo histogram 1.5.0 standard/tests/wrapping_sub().() { |
| 541 | let (h, h_good, h_overflow, h_mismatch) = build_histogramsrust-analyzer cargo histogram 1.5.0 standard/tests/build_histograms().(); |
| 542 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 543 | h.wrapping_subrust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram]wrapping_sub().(&h_mismatch), |
| 544 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo histogram 1.5.0 errors/Error#::IncompatibleParametersrust-analyzer cargo histogram 1.5.0 errors/Error#IncompatibleParameters#) |
| 545 | ); |
| 546 | let r = h.wrapping_subrust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram]wrapping_sub().(&h_good).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 547 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(r.as_slicerust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram]as_slice().(), &[0, 0, 0, 0, 0, 0]); |
| 548 | let r = h.wrapping_subrust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram]wrapping_sub().(&h_overflow).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 549 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(r.as_slicerust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram]as_slice().(), &[2, 2, 2, 2, 2, 2]); |
| 550 | } |
| 551 | |
| 552 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 553 | fn from_bucketsrust-analyzer cargo histogram 1.5.0 standard/tests/from_buckets().() { |
| 554 | let mut histogram = Histogramrust-analyzer cargo histogram 1.5.0 standard/Histogram#::newrust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram]new().(8, 32).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 555 | for i in 0..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#100 { |
| 556 | let _ = histogram.incrementrust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram]increment().(i); |
| 557 | } |
| 558 | let buckets = histogram.as_slicerust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram]as_slice().(); |
| 559 | let constructed = Histogramrust-analyzer cargo histogram 1.5.0 standard/Histogram#::from_bucketsrust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram]from_buckets().(8, 32, buckets.to_vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]to_vec().()).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 560 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(constructed == histogram); |
| 561 | } |
| 562 | |
| 563 | #[cfg(target_pointer_width = "64")] |
| 564 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 565 | fn size_u32rust-analyzer cargo histogram 1.5.0 standard/tests/size_u32().() { |
| 566 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::size_ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/size_of().::<Histogram32rust-analyzer cargo histogram 1.5.0 standard/Histogram32#>(), 48); |
| 567 | } |
| 568 | |
| 569 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 570 | fn increment_u32rust-analyzer cargo histogram 1.5.0 standard/tests/increment_u32().() { |
| 571 | let mut h = Histogram32rust-analyzer cargo histogram 1.5.0 standard/Histogram32#::newrust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram32]new().(7, 64).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 572 | h.incrementrust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram32]increment().(5).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 573 | h.incrementrust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram32]increment().(5).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 574 | h.incrementrust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram32]increment().(5).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 575 | let result = h.quantilerust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram32]quantile().(0.5).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 576 | let q = Quantilerust-analyzer cargo histogram 1.5.0 quantile/Quantile#::newrust-analyzer cargo histogram 1.5.0 quantile/impl#[Quantile]new().(0.5).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 577 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(result.getrust-analyzer cargo histogram 1.5.0 quantile/impl#[QuantilesResult]get().(&q).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().countrust-analyzer cargo histogram 1.5.0 bucket/impl#[Bucket]count().(), 3u64); |
| 578 | } |
| 579 | |
| 580 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 581 | fn add_u32_wraps_at_maxrust-analyzer cargo histogram 1.5.0 standard/tests/add_u32_wraps_at_max().() { |
| 582 | let mut h = Histogram32rust-analyzer cargo histogram 1.5.0 standard/Histogram32#::newrust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram32]new().(2, 4).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 583 | h.addrust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram32]add().(1, u32::MAXrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]MAX.).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 584 | h.addrust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram32]add().(1, 1).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 585 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(h.as_slicerust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram32]as_slice().()[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., 0u32); |
| 586 | } |
| 587 | |
| 588 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 589 | fn checked_add_u32_overflowrust-analyzer cargo histogram 1.5.0 standard/tests/checked_add_u32_overflow().() { |
| 590 | let mut h1 = Histogram32rust-analyzer cargo histogram 1.5.0 standard/Histogram32#::newrust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram32]new().(1, 3).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 591 | let mut h2 = Histogram32rust-analyzer cargo histogram 1.5.0 standard/Histogram32#::newrust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram32]new().(1, 3).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 592 | h1.as_mut_slicerust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram32]as_mut_slice().()[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). = u32::MAXrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]MAX.; |
| 593 | h2.as_mut_slicerust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram32]as_mut_slice().()[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). = 1; |
| 594 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(h1.checked_addrust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram32]checked_add().(&h2), Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo histogram 1.5.0 errors/Error#::Overflowrust-analyzer cargo histogram 1.5.0 errors/Error#Overflow#)); |
| 595 | } |
| 596 | |
| 597 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 598 | fn iter_u32_widens_count_to_u64rust-analyzer cargo histogram 1.5.0 standard/tests/iter_u32_widens_count_to_u64().() { |
| 599 | let mut h = Histogram32rust-analyzer cargo histogram 1.5.0 standard/Histogram32#::newrust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram32]new().(2, 4).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 600 | h.addrust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram32]add().(1, 5u32).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 601 | let bucket = h.iterrust-analyzer cargo histogram 1.5.0 standard/impl#[Histogram32]iter().().findrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#find().(|b| b.countrust-analyzer cargo histogram 1.5.0 bucket/impl#[Bucket]count().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]gt().0).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 602 | let count: u64 = bucket.countrust-analyzer cargo histogram 1.5.0 bucket/impl#[Bucket]count().(); |
| 603 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(count, 5); |
| 604 | } |
| 605 | } |