Trait enso_flexer::prelude::WeakElement[][src]

pub trait WeakElement {
    type Strong;
    fn new(view: &Self::Strong) -> Self;
fn view(&self) -> Option<Self::Strong>; fn is_expired(&self) -> bool { ... }
fn clone(view: &Self::Strong) -> Self::Strong { ... } }
Expand description

Interface for elements that can be stored in weak hash tables.

This trait applies to the weak version of a reference-counted pointer; it can be used to convert a weak pointer into a strong pointer and back. For example, the impl for std::rc::Weak<T> defines the Strong associated type as std::rc::Rc<T>. Then method new can be used to downgrade an Rc<T> to a Weak<T>, and method view can be used to upgrade a Weak<T> into an Rc<T>, if it’s still alive. If we think of the weak pointer as what is stored, then the strong pointer is a temporary view of it.

Associated Types

type Strong[src]

Expand description

The type at which a weak element can be viewed.

For example, for std::rc::Weak<T>, this will be std::rc::Rc<T>.

Loading content...

Required methods

fn new(view: &Self::Strong) -> Self[src]

Expand description

Constructs a weak pointer from a strong pointer.

This is usually implemented by a downgrade method.

fn view(&self) -> Option<Self::Strong>[src]

Expand description

Acquires a strong pointer from a weak pointer.

This is usually implemented by an upgrade method.

Loading content...

Provided methods

fn is_expired(&self) -> bool[src]

Expand description

Is the given weak element expired?

The default implemention checks whether a strong pointer can be obtained via view.

fn clone(view: &Self::Strong) -> Self::Strong[src]

Expand description

Clones a strong pointer.

The default implementation uses new and view; you should override it.

Loading content...

Implementations on Foreign Types

impl<T> WeakElement for Weak<T> where
    T: ?Sized
[src]

type Strong = Arc<T>

pub fn new(view: &<Weak<T> as WeakElement>::Strong) -> Weak<T>[src]

pub fn view(&self) -> Option<<Weak<T> as WeakElement>::Strong>[src]

pub fn clone(
    view: &<Weak<T> as WeakElement>::Strong
) -> <Weak<T> as WeakElement>::Strong
[src]

Loading content...

Implementors

impl<T> WeakElement for enso_flexer::prelude::Weak<T> where
    T: ?Sized
[src]

type Strong = Rc<T>

pub fn new(view: &<Weak<T> as WeakElement>::Strong) -> Weak<T>[src]

pub fn view(&self) -> Option<<Weak<T> as WeakElement>::Strong>[src]

pub fn clone(
    view: &<Weak<T> as WeakElement>::Strong
) -> <Weak<T> as WeakElement>::Strong
[src]

Loading content...