wgpu/
send_sync.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
use std::any::Any;
use std::fmt;

use wgt::WasmNotSendSync;

pub trait AnyWasmNotSendSync: Any + WasmNotSendSync {
    fn upcast_any_ref(&self) -> &dyn Any;
}
impl<T: Any + WasmNotSendSync> AnyWasmNotSendSync for T {
    #[inline]
    fn upcast_any_ref(&self) -> &dyn Any {
        self
    }
}

impl dyn AnyWasmNotSendSync + 'static {
    #[inline]
    pub fn downcast_ref<T: 'static>(&self) -> Option<&T> {
        self.upcast_any_ref().downcast_ref::<T>()
    }
}

impl fmt::Debug for dyn AnyWasmNotSendSync {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        f.debug_struct("Any").finish_non_exhaustive()
    }
}