File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change 56
56
}
57
57
}
58
58
59
+ impl < K , V > From < ( & K , & V ) > for Label
60
+ where
61
+ K : Into < SharedString > + Clone ,
62
+ V : Into < SharedString > + Clone ,
63
+ {
64
+ fn from ( pair : ( & K , & V ) ) -> Label {
65
+ Label :: new ( pair. 0 . clone ( ) , pair. 1 . clone ( ) )
66
+ }
67
+ }
68
+
59
69
/// A value that can be converted to a vector of [`Label`]s.
60
70
pub trait IntoLabels {
61
71
/// Consumes this value, turning it into a vector of [`Label`]s.
@@ -99,4 +109,14 @@ mod label_tests {
99
109
let expected = vec ! [ Label :: new( "x" , "a" ) , Label :: new( "y" , "b" ) ] ;
100
110
assert_eq ! ( from_slice_to_labels( & labels) , expected) ;
101
111
}
112
+
113
+ #[ test]
114
+ fn btreemap_to_labels ( ) {
115
+ use std:: collections:: BTreeMap ;
116
+
117
+ let labels_btreemap = BTreeMap :: from ( [ ( "customer" , "Rust Foundation" ) ] ) ;
118
+
119
+ let expected = vec ! [ Label :: new( "customer" , "Rust Foundation" ) ] ;
120
+ assert_eq ! ( labels_btreemap. into_labels( ) , expected) ;
121
+ }
102
122
}
You can’t perform that action at this time.
0 commit comments