diff --git a/CHANGELOG.md b/CHANGELOG.md index db4f606..3b9d4f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,15 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.23.1] - unreleased + +### Changed + +- `Histogram::new` now accepts an `IntoIterator` argument, rather than an `Iterator`. + See [PR 243]. + +[PR 243]: https://github.com/prometheus/client_rust/pull/243 + ## [0.23.0] ### Changed diff --git a/Cargo.toml b/Cargo.toml index 18dd395..d04c899 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "prometheus-client" -version = "0.23.0" +version = "0.23.1" authors = ["Max Inden "] edition = "2021" description = "Open Metrics client library allowing users to natively instrument applications." diff --git a/src/metrics/histogram.rs b/src/metrics/histogram.rs index f95ca8d..5a50278 100644 --- a/src/metrics/histogram.rs +++ b/src/metrics/histogram.rs @@ -28,7 +28,7 @@ use std::sync::Arc; /// let custom_buckets = [ /// 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0, 10.0, /// ]; -/// let histogram = Histogram::new(custom_buckets.into_iter()); +/// let histogram = Histogram::new(custom_buckets); /// histogram.observe(4.2); /// ``` // TODO: Consider using atomics. See @@ -57,7 +57,12 @@ pub(crate) struct Inner { impl Histogram { /// Create a new [`Histogram`]. - pub fn new(buckets: impl Iterator) -> Self { + /// + /// ```rust + /// # use prometheus_client::metrics::histogram::Histogram; + /// let histogram = Histogram::new([10.0, 100.0, 1_000.0]); + /// ``` + pub fn new(buckets: impl IntoIterator) -> Self { Self { inner: Arc::new(RwLock::new(Inner { sum: Default::default(),