Skip to content

Commit 81ee539

Browse files
committed
Add default implementation for as_any()
1 parent 21a98a3 commit 81ee539

File tree

1 file changed

+7
-1
lines changed
  • rust-runtime/aws-smithy-observability/src

1 file changed

+7
-1
lines changed

rust-runtime/aws-smithy-observability/src/meter.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@ pub trait ProvideMeter: Send + Sync + Debug + 'static {
1919
fn get_meter(&self, scope: &'static str, attributes: Option<&Attributes>) -> Meter;
2020

2121
/// Downcast to `Any` for type inspection.
22-
fn as_any(&self) -> &dyn std::any::Any;
22+
///
23+
/// The default implementation returns a reference to `()`, which will fail
24+
/// any downcast attempts. Implementors should override this method to return
25+
/// `self` for proper type inspection support.
26+
fn as_any(&self) -> &dyn std::any::Any {
27+
&()
28+
}
2329
}
2430

2531
/// The entry point to creating instruments. A grouping of related metrics.

0 commit comments

Comments
 (0)