@@ -193,8 +193,8 @@ impl Baggage {
193
193
194
194
/// Removes a name from the baggage, returning the value
195
195
/// corresponding to the name if the pair was previously in the map.
196
- pub fn remove < K : Into < Key > > ( & mut self , key : K ) -> Option < ( StringValue , BaggageMetadata ) > {
197
- self . inner . remove ( & key. into ( ) )
196
+ pub fn remove < K : AsRef < str > > ( & mut self , key : K ) -> Option < ( StringValue , BaggageMetadata ) > {
197
+ self . inner . remove ( key. as_ref ( ) )
198
198
}
199
199
200
200
/// Returns the number of attributes for this baggage
@@ -584,4 +584,25 @@ mod tests {
584
584
assert ! ( b. insert( "c" , StringValue :: from( ".." ) ) . is_none( ) ) ; // exceeds MAX_LEN_OF_ALL_PAIRS
585
585
assert_eq ! ( b. insert( "c" , StringValue :: from( "!" ) ) . unwrap( ) , "." . into( ) ) ; // replaces existing
586
586
}
587
+
588
+ #[ test]
589
+ fn test_crud_operations ( ) {
590
+ let mut baggage = Baggage :: default ( ) ;
591
+ assert ! ( baggage. is_empty( ) ) ;
592
+
593
+ // create
594
+ baggage. insert ( "foo" , "1" ) ;
595
+ assert_eq ! ( baggage. len( ) , 1 ) ;
596
+
597
+ // get
598
+ assert_eq ! ( baggage. get( "foo" ) , Some ( & StringValue :: from( "1" ) ) ) ;
599
+
600
+ // update
601
+ baggage. insert ( "foo" , "2" ) ;
602
+ assert_eq ! ( baggage. get( "foo" ) , Some ( & StringValue :: from( "2" ) ) ) ;
603
+
604
+ // delete
605
+ baggage. remove ( "foo" ) ;
606
+ assert ! ( baggage. is_empty( ) ) ;
607
+ }
587
608
}
0 commit comments