demo.rs
1 // If provided by either stable or unstable feature, have this target be non-empty. 2 #![cfg(any( 3 // Only set/true when the currently-used version of the cfg_rust_features crate supports it 4 // and it is stable in the currently-used version of Rust. 5 rust_lib_feature = "test", 6 // Only set/true when a nightly (or dev) compiler is being used. 7 rust_comp_feature = "unstable_features" 8 ))] 9 // Else, a stable compiler version without the feature is being used, so have this target be 10 // empty to cause all the below items to be ignored as if they do not exist. 11 #![cfg_attr( 12 // If the feature is still unstable 13 not(rust_lib_feature = "test"), 14 // then it needs to be specially enabled. 15 feature(test) 16 )] 17 // Else if the feature is stable, #![feature(test)] is not needed. 18 19 // Valid whenever the feature is enabled, whether stable or unstable. 20 extern crate test; 21 22 #[bench] 23 fn dummy(bencher: &mut test::Bencher) 24 { 25 bencher.iter(|| 1 + 1) 26 }