pub trait WeakElement {
type Strong;
// Required methods
fn new(view: &Self::Strong) -> Self;
fn view(&self) -> Option<Self::Strong>;
// Provided methods
fn is_expired(&self) -> bool { ... }
fn clone(view: &Self::Strong) -> Self::Strong
where Self: Sized { ... }
}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.
Required Associated Types§
Required Methods§
Provided Methods§
Sourcefn is_expired(&self) -> bool
fn is_expired(&self) -> bool
Is the given weak element expired?
The default implemention checks whether a strong pointer can be obtained via view.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.