pub fn downcast_borrow_ref<T>(&self) -> Result<BorrowRef<'_, T>, AccessError>
    where
        T: Any,
    {
        unsafe {
            let inner = self.inner.as_ref();
            let guard = inner.access.shared(AccessKind::Any)?;
            let expected = Hash::from_type_id(any::TypeId::of::<T>());

            let data = match (*inner.data.get()).raw_as_ptr(expected) {
                Ok(data) => data,
                Err(AnyObjError::Cast) => {
                    return Err(AccessError::UnexpectedType {
                        expected: any::type_name::<T>().into(),
                        actual: (*inner.data.get()).type_name(),
                    });
                }
                Err(e) => {
                    return Err(e.into());
                }
            };

            mem::forget(guard);
            Ok(BorrowRef::new(&*(data as *const T), &inner.access))
        }
    }
/// Get an shared, downcasted reference to the contained value.
Get an shared, downcasted reference to the contained value.
Get an shared downcasted reference to the contained value .
pub fn downcast_borrow_ref<T>(&self) -> Result<BorrowRef<'_, T>, AccessError>
    where
        T: Any,
    {
        unsafe {
            let inner = self.inner.as_ref();
            let guard = inner.access.shared(AccessKind::Any)?;
            let expected = Hash::from_type_id(any::TypeId::of::<T>());
            let data = match (*inner.data.get()).raw_as_ptr(expected) {
                Ok(data) => data,
                Err(AnyObjError::Cast) => {
                    return Err(AccessError::UnexpectedType {
                        expected: any::type_name::<T>().into(),
                        actual: (*inner.data.get()).type_name(),
                    });
                }
                Err(e) => {
                    return Err(e.into());
                }
            };
            mem::forget(guard);
            Ok(BorrowRef::new(&*(data as *const T), &inner.access))
        }
    }
pub fn downcast_borrow_ref < T > ( & self ) -> Result < BorrowRef < ' _ , T > , AccessError > where T : Any , { unsafe { let inner = self . inner . as_ref ( ) ; let guard = inner . access . shared ( AccessKind :: Any ) ? ; let expected = Hash :: from_type_id ( any :: TypeId :: of :: < T > ( ) ) ; let data = match ( * inner . data . get ( ) ) . raw_as_ptr ( expected ) { Ok ( data ) => data , Err ( AnyObjError :: Cast ) => { return Err ( AccessError :: UnexpectedType { expected : any :: type_name :: < T > ( ) . into ( ) , actual : ( * inner . data . get ( ) ) . type_name ( ) , } ) ; } Err ( e ) => { return Err ( e . into ( ) ) ; } } ; mem :: forget ( guard ) ; Ok ( BorrowRef :: new ( & * ( data as * const T ) , & inner . access ) ) } }
Get an shared, downcasted reference to the contained value.
Get an shared downcasted reference to the contained value .
&self
&self