mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-19 18:34:08 +00:00
Auto merge of #30928 - sfackler:any-unsized, r=aturon
This is a bit weird since unsized types can't be used in trait objects, but Any is *also* used as pure marker trait since Reflect isn't stable. There are many cases (e.g. TypeMap) where all you need is a TypeId. r? @aturon
This commit is contained in:
commit
87608746f0
@ -99,7 +99,7 @@ pub trait Any: Reflect + 'static {
|
||||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<T: Reflect + 'static> Any for T {
|
||||
impl<T: Reflect + 'static + ?Sized > Any for T {
|
||||
fn get_type_id(&self) -> TypeId { TypeId::of::<T>() }
|
||||
}
|
||||
|
||||
|
@ -119,6 +119,11 @@ fn any_fixed_vec() {
|
||||
assert!(!test.is::<[usize; 10]>());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn any_unsized() {
|
||||
fn is_any<T: Any + ?Sized>() {}
|
||||
is_any::<[i32]>();
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn bench_downcast_ref(b: &mut Bencher) {
|
||||
|
Loading…
Reference in New Issue
Block a user