@@ -33,23 +33,23 @@ pub trait BackendStats {
3333 const NAME : & ' static str ;
3434}
3535
36- impl BackendStats for backend:: BucketBackend < DefaultSymbol > {
36+ impl BackendStats for backend:: BucketBackend < ' _ , DefaultSymbol > {
3737 const MIN_OVERHEAD : f64 = 2.2 ;
3838 const MAX_OVERHEAD : f64 = 3.1 ;
3939 const MAX_ALLOCATIONS : usize = 65 ;
4040 const MAX_DEALLOCATIONS : usize = 42 ;
4141 const NAME : & ' static str = "BucketBackend" ;
4242}
4343
44- impl BackendStats for backend:: StringBackend < DefaultSymbol > {
44+ impl BackendStats for backend:: StringBackend < ' _ , DefaultSymbol > {
4545 const MIN_OVERHEAD : f64 = 1.7 ;
4646 const MAX_OVERHEAD : f64 = 1.93 ;
4747 const MAX_ALLOCATIONS : usize = 62 ;
4848 const MAX_DEALLOCATIONS : usize = 59 ;
4949 const NAME : & ' static str = "StringBackend" ;
5050}
5151
52- impl BackendStats for backend:: BufferBackend < DefaultSymbol > {
52+ impl BackendStats for backend:: BufferBackend < ' _ , DefaultSymbol > {
5353 const MIN_OVERHEAD : f64 = 1.35 ;
5454 const MAX_OVERHEAD : f64 = 1.58 ;
5555 const MAX_ALLOCATIONS : usize = 43 ;
@@ -68,9 +68,12 @@ pub struct ProfilingStats {
6868}
6969
7070macro_rules! gen_tests_for_backend {
71- ( $backend: ty ) => {
72- type StringInterner =
73- string_interner:: StringInterner <$backend, DefaultHashBuilder >;
71+ ( $backend: ident ) => {
72+ gen_tests_for_backend!( $backend, symbol: DefaultSymbol ) ;
73+ } ;
74+ ( $backend: ident, symbol: $symbol: ident ) => {
75+ type StringInterner <' i> =
76+ string_interner:: StringInterner <' i, backend:: $backend<' i, $symbol>, DefaultHashBuilder >;
7477
7578 fn profile_memory_usage( words: & [ String ] ) -> ProfilingStats {
7679 ALLOCATOR . reset( ) ;
@@ -128,7 +131,7 @@ macro_rules! gen_tests_for_backend {
128131 } ) . collect:: <Vec <_>>( ) ;
129132
130133 println!( ) ;
131- println!( "Benchmark Memory Usage for {}" , <$backend as BackendStats >:: NAME ) ;
134+ println!( "Benchmark Memory Usage for {}" , <backend :: $backend<$symbol> as BackendStats >:: NAME ) ;
132135 let mut min_overhead = None ;
133136 let mut max_overhead = None ;
134137 let mut max_allocations = None ;
@@ -152,12 +155,12 @@ macro_rules! gen_tests_for_backend {
152155 }
153156 let actual_min_overhead = min_overhead. unwrap( ) ;
154157 let actual_max_overhead = max_overhead. unwrap( ) ;
155- let expect_min_overhead = <$backend as BackendStats >:: MIN_OVERHEAD ;
156- let expect_max_overhead = <$backend as BackendStats >:: MAX_OVERHEAD ;
158+ let expect_min_overhead = <backend :: $backend<$symbol> as BackendStats >:: MIN_OVERHEAD ;
159+ let expect_max_overhead = <backend :: $backend<$symbol> as BackendStats >:: MAX_OVERHEAD ;
157160 let actual_max_allocations = max_allocations. unwrap( ) ;
158161 let actual_max_deallocations = max_deallocations. unwrap( ) ;
159- let expect_max_allocations = <$backend as BackendStats >:: MAX_ALLOCATIONS ;
160- let expect_max_deallocations = <$backend as BackendStats >:: MAX_DEALLOCATIONS ;
162+ let expect_max_allocations = <backend :: $backend<$symbol> as BackendStats >:: MAX_ALLOCATIONS ;
163+ let expect_max_deallocations = <backend :: $backend<$symbol> as BackendStats >:: MAX_DEALLOCATIONS ;
161164
162165 println!( ) ;
163166 println!( "- % min overhead = {:.02}%" , actual_min_overhead * 100.0 ) ;
@@ -168,28 +171,28 @@ macro_rules! gen_tests_for_backend {
168171 assert!(
169172 actual_min_overhead < expect_min_overhead,
170173 "{} string interner backend minimum memory overhead is greater than expected. expected = {:?}, actual = {:?}" ,
171- <$backend as BackendStats >:: NAME ,
174+ <backend :: $backend<$symbol> as BackendStats >:: NAME ,
172175 expect_min_overhead,
173176 actual_min_overhead,
174177 ) ;
175178 assert!(
176179 actual_max_overhead < expect_max_overhead,
177180 "{} string interner backend maximum memory overhead is greater than expected. expected = {:?}, actual = {:?}" ,
178- <$backend as BackendStats >:: NAME ,
181+ <backend :: $backend<$symbol> as BackendStats >:: NAME ,
179182 expect_max_overhead,
180183 actual_max_overhead,
181184 ) ;
182185 assert_eq!(
183186 actual_max_allocations, expect_max_allocations,
184187 "{} string interner backend maximum amount of allocations is greater than expected. expected = {:?}, actual = {:?}" ,
185- <$backend as BackendStats >:: NAME ,
188+ <backend :: $backend<$symbol> as BackendStats >:: NAME ,
186189 expect_max_allocations,
187190 actual_max_allocations,
188191 ) ;
189192 assert_eq!(
190193 actual_max_deallocations, expect_max_deallocations,
191194 "{} string interner backend maximum amount of deallocations is greater than expected. expected = {:?}, actual = {:?}" ,
192- <$backend as BackendStats >:: NAME ,
195+ <backend :: $backend<$symbol> as BackendStats >:: NAME ,
193196 expect_max_deallocations,
194197 actual_max_deallocations,
195198 ) ;
@@ -414,17 +417,17 @@ macro_rules! gen_tests_for_backend {
414417mod bucket_backend {
415418 use super :: * ;
416419
417- gen_tests_for_backend ! ( backend :: BucketBackend < DefaultSymbol > ) ;
420+ gen_tests_for_backend ! ( BucketBackend ) ;
418421}
419422
420423mod string_backend {
421424 use super :: * ;
422425
423- gen_tests_for_backend ! ( backend :: StringBackend < DefaultSymbol > ) ;
426+ gen_tests_for_backend ! ( StringBackend ) ;
424427}
425428
426429mod buffer_backend {
427430 use super :: * ;
428431
429- gen_tests_for_backend ! ( backend :: BufferBackend < DefaultSymbol > ) ;
432+ gen_tests_for_backend ! ( BufferBackend ) ;
430433}
0 commit comments