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>>>>

[src]

🔬 This is a nightly-only experimental API. (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]

[src]

Returns the "default value" for a type. Read more

impl<T: Debug + Default> Debug for PoolObjectHandler<T>
[src]

[src]

Formats the value using the given formatter.

impl<T: PartialEq + Default> PartialEq for PoolObjectHandler<T>
[src]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

[src]

This method tests for !=.

impl<T: Default> Deref for PoolObjectHandler<T>
[src]

The resulting type after dereferencing.

[src]

Dereferences the value.

impl<T: Default> Drop for PoolObjectHandler<T>
[src]

[src]

Executes the destructor for this type. Read more

impl<T: Default> Clone for PoolObjectHandler<T>
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more