Commit 885dd9d 1 parent 0303a38 commit 885dd9d Copy full SHA for 885dd9d
File tree 2 files changed +17
-5
lines changed
2 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -75,8 +75,8 @@ impl Baggage {
75
75
///
76
76
/// assert_eq!(cc.get("my-name"), Some(&Value::from("my-value")))
77
77
/// ```
78
- pub fn get < T : Into < Key > > ( & self , key : T ) -> Option < & Value > {
79
- self . inner . get ( & key. into ( ) ) . map ( |( value, _metadata) | value)
78
+ pub fn get < K : AsRef < str > > ( & self , key : K ) -> Option < & Value > {
79
+ self . inner . get ( key. as_ref ( ) ) . map ( |( value, _metadata) | value)
80
80
}
81
81
82
82
/// Returns a reference to the value and metadata associated with a given name
@@ -91,8 +91,8 @@ impl Baggage {
91
91
/// // By default, the metadata is empty
92
92
/// assert_eq!(cc.get_with_metadata("my-name"), Some(&(Value::from("my-value"), BaggageMetadata::from(""))))
93
93
/// ```
94
- pub fn get_with_metadata < T : Into < Key > > ( & self , key : T ) -> Option < & ( Value , BaggageMetadata ) > {
95
- self . inner . get ( & key. into ( ) )
94
+ pub fn get_with_metadata < K : AsRef < str > > ( & self , key : K ) -> Option < & ( Value , BaggageMetadata ) > {
95
+ self . inner . get ( key. as_ref ( ) )
96
96
}
97
97
98
98
/// Inserts a name/value pair into the baggage.
Original file line number Diff line number Diff line change 1
- use std:: borrow:: Cow ;
1
+ use std:: borrow:: { Borrow , Cow } ;
2
2
use std:: sync:: Arc ;
3
3
use std:: { fmt, hash} ;
4
4
@@ -135,6 +135,18 @@ impl fmt::Display for Key {
135
135
}
136
136
}
137
137
138
+ impl Borrow < str > for Key {
139
+ fn borrow ( & self ) -> & str {
140
+ self . 0 . as_str ( )
141
+ }
142
+ }
143
+
144
+ impl AsRef < str > for Key {
145
+ fn as_ref ( & self ) -> & str {
146
+ self . 0 . as_str ( )
147
+ }
148
+ }
149
+
138
150
#[ derive( Clone , Debug , Eq ) ]
139
151
enum OtelString {
140
152
Owned ( Box < str > ) ,
You can’t perform that action at this time.
0 commit comments