Struct maskerad_object_pool::Handler
[−]
[src]
pub struct Handler<T: Default>(pub Rc<RefCell<PoolObject<T>>>);
A wrapper around a reference-counted pointer to a PoolObject with interior mutability.
The poolObject is wrapped by a RefCell, to be able to mutate the PoolObject with an immutable reference.
This RefCell is wrapped by an Rc, a reference-counted pointer, so multiple parts of the program can "own" the Refcell.
This wrapper allow a custom drop implementation: when a Handler is dropped, the contained PoolObject is reinitialized to a default non-used state.
Methods from Deref<Target = Rc<RefCell<PoolObject<T>>>>
fn downcast<T>(self) -> Result<Rc<T>, Rc<Any + 'static>> where
T: Any,
[src]
T: Any,
rc_downcast
)Attempt to downcast the Rc<Any>
to a concrete type.
Examples
#![feature(rc_downcast)] use std::any::Any; use std::rc::Rc; fn print_if_string(value: Rc<Any>) { if let Ok(string) = value.downcast::<String>() { println!("String ({}): {}", string.len(), string); } } fn main() { let my_string = "Hello World".to_string(); print_if_string(Rc::new(my_string)); print_if_string(Rc::new(0i8)); }
Trait Implementations
impl<T: Default + Default> Default for PoolObjectHandler<T>
[src]
fn default() -> PoolObjectHandler<T>
[src]
Returns the "default value" for a type. Read more
impl<T: Debug + Default> Debug for PoolObjectHandler<T>
[src]
impl<T: PartialEq + Default> PartialEq for PoolObjectHandler<T>
[src]
fn eq(&self, __arg_0: &PoolObjectHandler<T>) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &PoolObjectHandler<T>) -> bool
[src]
This method tests for !=
.
impl<T: Default> Deref for PoolObjectHandler<T>
[src]
type Target = Rc<RefCell<PoolObject<T>>>
The resulting type after dereferencing.
fn deref(&self) -> &Rc<RefCell<PoolObject<T>>>
[src]
Dereferences the value.
impl<T: Default> Drop for PoolObjectHandler<T>
[src]
impl<T: Default> Clone for PoolObjectHandler<T>
[src]
fn clone(&self) -> PoolObjectHandler<T>
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more