[−][src]Struct runestick::Any
Our own private dynamic Any implementation.
In contrast to Box<dyn std::any::Any>
, this allows for storing a raw
pointer directly in the object to avoid one level of indirection. Otherwise
it's equivalent.
Implementations
impl Any
[src]
pub fn new<T>(data: T) -> Self where
T: Any,
[src]
T: Any,
Construct a new any from the original any.
pub fn is<T>(&self) -> bool where
T: Any,
[src]
T: Any,
Returns true
if the boxed type is the same as T
.
Examples
let any = runestick::Any::new(1u32); assert!(any.is::<u32>());
pub fn downcast_borrow_ref<T>(&self) -> Option<&T> where
T: Any,
[src]
T: Any,
Returns some reference to the boxed value if it is of type T
, or
None
if it isn't.
Examples
let any = runestick::Any::new(1u32); assert_eq!(Some(&1u32), any.downcast_borrow_ref::<u32>()); assert_eq!(None, any.downcast_borrow_ref::<&u32>());
pub fn downcast_borrow_mut<T>(&mut self) -> Option<&mut T> where
T: Any,
[src]
T: Any,
Returns some mutable reference to the boxed value if it is of type T
, or
None
if it isn't.
Examples
let mut any = runestick::Any::new(1u32); *any.downcast_borrow_mut::<u32>().unwrap() = 2; assert_eq!(Some(&2u32), any.downcast_borrow_ref::<u32>());
pub fn as_ptr(&self, expected: TypeId) -> Option<*const ()>
[src]
Attempt to perform a conversion to a raw pointer.
pub fn as_mut_ptr(&mut self, expected: TypeId) -> Option<*mut ()>
[src]
Attempt to perform a conversion to a raw mutable pointer.
pub fn take_mut_ptr(self, expected: TypeId) -> Result<*mut (), Self>
[src]
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 fn type_name(&self) -> &'static str
[src]
Access the underlying type name for the data.
pub fn type_hash(&self) -> Hash
[src]
Access the underlying type id for the data.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Any
impl !Send for Any
impl !Sync for Any
impl Unpin for Any
impl UnwindSafe for Any
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,