UnsafeObject

Struct UnsafeObject 

Source
pub struct UnsafeObject { /* private fields */ }
Expand description

Smart pointer point to object stored in Bump It use TypeId to check when downcast in runtime, so only ’static type supported

Implementations§

Source§

impl UnsafeObject

Source

pub unsafe fn new<T>(bump: &Bump, inner: T) -> Self
where T: Send + 'static,

§Safety

the safety depends on Bump used to create this object not reset or droped while this object is still live

Source

pub fn is<T>(&self) -> bool
where T: 'static,

Check if this object is of type T

Source

pub unsafe fn downcast_ref<T>(&self) -> Option<&T>
where T: 'static,

§Safety

The safety depends on Bump used to create this object not reset or droped while this object is still live if this object is of type T, will return the reference of T otherwise will return None

Source

pub unsafe fn downcast_mut<T>(&mut self) -> Option<&mut T>
where T: 'static,

§Safety

The safety depends on Bump used to create this object not reset or droped while this object is still live if this object is of type T, will return the mutable reference of T otherwise will return None

Trait Implementations§

Source§

impl Drop for UnsafeObject

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.