From f46787aea1006961405981baa2cea5851e60157a Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Sat, 13 Dec 2025 07:27:12 -0500 Subject: [PATCH] feat(metrics): Make noop() constructors const fn MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This allows Counter::noop(), Gauge::noop(), and Histogram::noop() to be used in const contexts like static variables. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- metrics/src/handles.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/metrics/src/handles.rs b/metrics/src/handles.rs index 33123aa7..f24817fe 100644 --- a/metrics/src/handles.rs +++ b/metrics/src/handles.rs @@ -89,7 +89,7 @@ impl Counter { /// /// Suitable when a handle must be provided that does nothing i.e. a no-op recorder or a layer /// that disables specific metrics, and so on. - pub fn noop() -> Self { + pub const fn noop() -> Self { Self { inner: None } } @@ -118,7 +118,7 @@ impl Gauge { /// /// Suitable when a handle must be provided that does nothing i.e. a no-op recorder or a layer /// that disables specific metrics, and so on. - pub fn noop() -> Self { + pub const fn noop() -> Self { Self { inner: None } } @@ -154,7 +154,7 @@ impl Histogram { /// /// Suitable when a handle must be provided that does nothing i.e. a no-op recorder or a layer /// that disables specific metrics, and so on. - pub fn noop() -> Self { + pub const fn noop() -> Self { Self { inner: None } }