pub fn try_extract_typed<T: 'static>(mut self) -> Result<T, Self> {
    let type_id = std::any::TypeId::of::<T>();
    if self.type_id != type_id {
      return Err(self);
    }
    let x: Box<T> = unsafe { Box::from_raw(self.data as *mut T) };
    self.data = std::ptr::null_mut(); // Clear out the content, it's invalid now
    std::mem::drop(self.type_id); // In case this type actually holds more than just an int
    std::mem::forget(self); // Prevent VTDroppable's Drop from being called on invalid values
    Ok(*x)
  }
/// Note that a failed extraction returns the unextracted form, which will be dropped if ignored
Note that a failed extraction returns the unextracted form, which will be dropped if ignored
Note that a failed extraction returns the unextracted form which will be dropped if ignored
pub fn try_extract_typed<T: 'static>(mut self) -> Result<T, Self> {
    let type_id = std::any::TypeId::of::<T>();
    if self.type_id != type_id {
      return Err(self);
    }
    let x: Box<T> = unsafe { Box::from_raw(self.data as *mut T) };
    self.data = std::ptr::null_mut(); // Clear out the content, it's invalid now
    std::mem::drop(self.type_id); // In case this type actually holds more than just an int
    std::mem::forget(self); // Prevent VTDroppable's Drop from being called on invalid values
    Ok(*x)
  }
pub fn try_extract_typed < T : ' static > ( mut self ) -> Result < T , Self > { let type_id = std :: any :: TypeId :: of :: < T > ( ) ; if self . type_id != type_id { return Err ( self ) ; } let x : Box < T > = unsafe { Box :: from_raw ( self . data as * mut T ) } ; self . data = std :: ptr :: null_mut ( ) ; // Clear out the content, it's invalid now std :: mem :: drop ( self . type_id ) ; // In case this type actually holds more than just an int std :: mem :: forget ( self ) ; // Prevent VTDroppable's Drop from being called on invalid values Ok ( * x ) }
Note that a failed extraction returns the unextracted form, which will be dropped if ignored
Note that a failed extraction returns the unextracted form which will be dropped if ignored
mut self
mut self