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