pub(crate) fn raw_take(self, expected: Hash) -> Result<*mut (), (AnyObjError, Self)> {
        match self.vtable.kind {
            // Only owned things can be taken.
            AnyObjKind::Owned => (),
            AnyObjKind::RefPtr => {
                return Err((
                    AnyObjError::RefAsOwned {
                        name: self.type_name(),
                    },
                    self,
                ))
            }
            AnyObjKind::MutPtr => {
                return Err((
                    AnyObjError::MutAsOwned {
                        name: self.type_name(),
                    },
                    self,
                ))
            }
        };

        let this = ManuallyDrop::new(self);

        // Safety: invariants are checked at construction time.
        // We have mutable access to the inner value because we have mutable
        // access to the `Any`.
        unsafe {
            match (this.vtable.as_ptr)(this.data, expected) {
                Some(data) => Ok(data as *mut ()),
                None => {
                    let this = ManuallyDrop::into_inner(this);
                    Err((AnyObjError::Cast, this))
                }
            }
        }
    }
/// Attempt to perform a conversion to a raw mutable pointer with the intent
/// of taking it.
///
/// If the conversion is not possible, we return a reconstructed `Any` as
/// the error variant.
Attempt to perform a conversion to a raw mutable pointer with the intent
of taking it.

If the conversion is not possible, we return a reconstructed `Any` as
the error variant.
Attempt to perform a conversion to a raw mutable pointer with the intent of taking it . If the conversion is not possible we return a reconstructed ` Any ` as the error variant .
pub(crate) fn raw_take(self, expected: Hash) -> Result<*mut (), (AnyObjError, Self)> {
        match self.vtable.kind {
            // Only owned things can be taken.
            AnyObjKind::Owned => (),
            AnyObjKind::RefPtr => {
                return Err((
                    AnyObjError::RefAsOwned {
                        name: self.type_name(),
                    },
                    self,
                ))
            }
            AnyObjKind::MutPtr => {
                return Err((
                    AnyObjError::MutAsOwned {
                        name: self.type_name(),
                    },
                    self,
                ))
            }
        };
        let this = ManuallyDrop::new(self);
        // Safety: invariants are checked at construction time.
        // We have mutable access to the inner value because we have mutable
        // access to the `Any`.
        unsafe {
            match (this.vtable.as_ptr)(this.data, expected) {
                Some(data) => Ok(data as *mut ()),
                None => {
                    let this = ManuallyDrop::into_inner(this);
                    Err((AnyObjError::Cast, this))
                }
            }
        }
    }
pub ( crate ) fn raw_take ( self , expected : Hash ) -> Result < * mut ( ) , ( AnyObjError , Self ) > { match self . vtable . kind { // Only owned things can be taken. AnyObjKind :: Owned => ( ) , AnyObjKind :: RefPtr => { return Err ( ( AnyObjError :: RefAsOwned { name : self . type_name ( ) , } , self , ) ) } AnyObjKind :: MutPtr => { return Err ( ( AnyObjError :: MutAsOwned { name : self . type_name ( ) , } , self , ) ) } } ; let this = ManuallyDrop :: new ( self ) ; // Safety: invariants are checked at construction time. // We have mutable access to the inner value because we have mutable // access to the `Any`. unsafe { match ( this . vtable . as_ptr ) ( this . data , expected ) { Some ( data ) => Ok ( data as * mut ( ) ) , None => { let this = ManuallyDrop :: into_inner ( this ) ; Err ( ( AnyObjError :: Cast , this ) ) } } } }
Attempt to perform a conversion to a raw mutable pointer with the intent
of taking it.
Attempt to perform a conversion to a raw mutable pointer with the intent of taking it .
self
expected
Hash
self
expected
Hash