88// option. This file may not be copied, modified, or distributed
99// except according to those terms.
1010
11+ #[ cfg( feature = "bench" ) ]
1112use std:: iter;
13+ #[ cfg( feature = "bench" ) ]
1214use test:: { self , Bencher } ;
13-
15+ # [ cfg ( feature = "bench" ) ]
1416use super :: UnicodeWidthChar ;
1517
16- #[ cfg( feature = "no_std" ) ]
1718use std:: prelude:: v1:: * ;
1819
20+ #[ cfg( feature = "bench" ) ]
1921#[ bench]
2022fn cargo ( b : & mut Bencher ) {
2123 let string = iter:: repeat ( 'a' ) . take ( 4096 ) . collect :: < String > ( ) ;
@@ -27,6 +29,7 @@ fn cargo(b: &mut Bencher) {
2729 } ) ;
2830}
2931
32+ #[ cfg( feature = "bench" ) ]
3033#[ bench]
3134#[ allow( deprecated) ]
3235fn stdlib ( b : & mut Bencher ) {
@@ -39,6 +42,7 @@ fn stdlib(b: &mut Bencher) {
3942 } ) ;
4043}
4144
45+ #[ cfg( feature = "bench" ) ]
4246#[ bench]
4347fn simple_if ( b : & mut Bencher ) {
4448 let string = iter:: repeat ( 'a' ) . take ( 4096 ) . collect :: < String > ( ) ;
@@ -50,6 +54,7 @@ fn simple_if(b: &mut Bencher) {
5054 } ) ;
5155}
5256
57+ #[ cfg( feature = "bench" ) ]
5358#[ bench]
5459fn simple_match ( b : & mut Bencher ) {
5560 let string = iter:: repeat ( 'a' ) . take ( 4096 ) . collect :: < String > ( ) ;
@@ -61,6 +66,7 @@ fn simple_match(b: &mut Bencher) {
6166 } ) ;
6267}
6368
69+ #[ cfg( feature = "bench" ) ]
6470#[ inline]
6571fn simple_width_if ( c : char ) -> Option < usize > {
6672 let cu = c as u32 ;
@@ -77,6 +83,7 @@ fn simple_width_if(c: char) -> Option<usize> {
7783 }
7884}
7985
86+ #[ cfg( feature = "bench" ) ]
8087#[ inline]
8188fn simple_width_match ( c : char ) -> Option < usize > {
8289 match c as u32 {
0 commit comments