@@ -141,7 +141,7 @@ fn test_opts_trailing_comma() {
141141/// let opts = histogram_opts!(name,
142142/// help,
143143/// vec![1.0, 2.0],
144- /// labels!{"key".to_string() => "value".to_string() ,});
144+ /// labels!{"key" => "value",});
145145/// assert_eq!(opts.common_opts.name, name);
146146/// assert_eq!(opts.common_opts.help, help);
147147/// assert_eq!(opts.buckets.len(), 2);
@@ -160,9 +160,10 @@ macro_rules! histogram_opts {
160160 hopts. buckets( $BUCKETS)
161161 } } ;
162162
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+
164166 let hopts = histogram_opts!( $NAME, $HELP, $BUCKETS) ;
165-
166167 let lbs = HashMap :: <String , String >:: new( ) ;
167168 $(
168169 let mut lbs = lbs;
@@ -193,13 +194,16 @@ fn test_histogram_opts_trailing_comma() {
193194 name,
194195 help,
195196 vec![ 1.0 , 2.0 ] ,
196- labels! { "key" . to_string( ) => "value" . to_string( ) , } ,
197+ labels! { "key" => "value" , } ,
198+ labels! { "key2" => "value2" , } ,
197199 ) ;
198200 assert_eq ! ( opts. common_opts. name, name) ;
199201 assert_eq ! ( opts. common_opts. help, help) ;
200202 assert_eq ! ( opts. buckets. len( ) , 2 ) ;
201203 assert ! ( opts. common_opts. const_labels. get( "key" ) . is_some( ) ) ;
202204 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" ) ;
203207}
204208
205209/// Create a [`Counter`] and registers to default registry.
0 commit comments