2017-02-03 17:04:22 -06:00
|
|
|
use core::any::*;
|
2019-12-06 22:18:12 -06:00
|
|
|
use test::{black_box, Bencher};
|
2017-02-03 17:04:22 -06:00
|
|
|
|
|
|
|
#[bench]
|
|
|
|
fn bench_downcast_ref(b: &mut Bencher) {
|
|
|
|
b.iter(|| {
|
|
|
|
let mut x = 0;
|
2018-08-29 05:18:05 -05:00
|
|
|
let mut y = &mut x as &mut dyn Any;
|
2017-02-03 17:04:22 -06:00
|
|
|
black_box(&mut y);
|
|
|
|
black_box(y.downcast_ref::<isize>() == Some(&0));
|
|
|
|
});
|
|
|
|
}
|