diff --git a/CHANGELOG.md b/CHANGELOG.md index c398e073..87a2a79f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,8 +18,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Implement `Atomic` for `AtomicU64` for gauges. See [PR 226]. -[PR 226]: https://github.com/prometheus/client_rust/pull/198 +- Implement `EnableLabelValue` for bool. + See [PR 237] + +[PR 173]: https://github.com/prometheus/client_rust/pull/173 [PR 198]: https://github.com/prometheus/client_rust/pull/198 +[PR 226]: https://github.com/prometheus/client_rust/pull/226 +[PR 237]: https://github.com/prometheus/client_rust/pull/237 ### Added diff --git a/src/encoding.rs b/src/encoding.rs index 2be2d375..564e6c5f 100644 --- a/src/encoding.rs +++ b/src/encoding.rs @@ -537,6 +537,12 @@ where } } +impl EncodeLabelValue for bool { + fn encode(&self, encoder: &mut LabelValueEncoder) -> Result<(), std::fmt::Error> { + encoder.write_str(if *self { "true" } else { "false" }) + } +} + macro_rules! impl_encode_label_value_for_integer { ($($t:ident),*) => {$( impl EncodeLabelValue for $t {