@@ -141,7 +141,7 @@ fn test_opts_trailing_comma() {
141
141
/// let opts = histogram_opts!(name,
142
142
/// help,
143
143
/// vec![1.0, 2.0],
144
- /// labels!{"key".to_string() => "value".to_string() ,});
144
+ /// labels!{"key" => "value",});
145
145
/// assert_eq!(opts.common_opts.name, name);
146
146
/// assert_eq!(opts.common_opts.help, help);
147
147
/// assert_eq!(opts.buckets.len(), 2);
@@ -160,9 +160,10 @@ macro_rules! histogram_opts {
160
160
hopts. buckets( $BUCKETS)
161
161
} } ;
162
162
163
- ( $NAME: expr, $HELP: expr, $BUCKETS: expr, $CONST_LABELS: expr $( , ) ?) => { {
163
+ ( $NAME: expr, $HELP: expr, $BUCKETS: expr $ ( , $CONST_LABELS: expr ) * $ ( , ) ? ) => { {
164
+ use std:: collections:: HashMap ;
165
+
164
166
let hopts = histogram_opts!( $NAME, $HELP, $BUCKETS) ;
165
-
166
167
let lbs = HashMap :: <String , String >:: new( ) ;
167
168
$(
168
169
let mut lbs = lbs;
@@ -193,13 +194,16 @@ fn test_histogram_opts_trailing_comma() {
193
194
name,
194
195
help,
195
196
vec![ 1.0 , 2.0 ] ,
196
- labels! { "key" . to_string( ) => "value" . to_string( ) , } ,
197
+ labels! { "key" => "value" , } ,
198
+ labels! { "key2" => "value2" , } ,
197
199
) ;
198
200
assert_eq ! ( opts. common_opts. name, name) ;
199
201
assert_eq ! ( opts. common_opts. help, help) ;
200
202
assert_eq ! ( opts. buckets. len( ) , 2 ) ;
201
203
assert ! ( opts. common_opts. const_labels. get( "key" ) . is_some( ) ) ;
202
204
assert_eq ! ( opts. common_opts. const_labels. get( "key" ) . unwrap( ) , "value" ) ;
205
+ assert ! ( opts. common_opts. const_labels. get( "key2" ) . is_some( ) ) ;
206
+ assert_eq ! ( opts. common_opts. const_labels. get( "key2" ) . unwrap( ) , "value2" ) ;
203
207
}
204
208
205
209
/// Create a [`Counter`] and registers to default registry.
0 commit comments