rstd 0.1.0
Loading...
Searching...
No Matches
alloc::rc::Weak< T > Class Template Referencefinalexport
module rstd.alloc

A non-owning reference to an Rc-managed allocation that does not prevent deallocation. More...

Public Member Functions

 Weak () noexcept
 Creates an empty Weak pointer.
 
 Weak (const Weak &other) noexcept
 Copy constructs a Weak pointer, incrementing the weak count.
 
 Weak (Weak &&other) noexcept
 Move constructs a Weak pointer, taking ownership from other.
 
auto clone () const noexcept -> Weak
 Creates a new Weak pointer to the same allocation.
 
auto upgrade () const -> Option< Rc< T > >
 Attempts to upgrade the Weak pointer to an Rc, returning None if the value has been dropped.
 
auto strong_count () const -> usize
 Returns the number of strong (Rc) pointers to the same allocation.
 
auto weak_count () const -> usize
 Returns the number of Weak pointers to the same allocation.
 

Detailed Description

template<typename T>
class alloc::rc::Weak< T >

A non-owning reference to an Rc-managed allocation that does not prevent deallocation.

Template Parameters
TThe type of the referenced value.

Member Function Documentation

◆ clone()

template<typename T >
auto alloc::rc::Weak< T >::clone ( ) const -> Weak
inlinenoexcept

Creates a new Weak pointer to the same allocation.

Returns
A cloned Weak pointer.

◆ strong_count()

template<typename T >
auto alloc::rc::Weak< T >::strong_count ( ) const -> usize
inline

Returns the number of strong (Rc) pointers to the same allocation.

Returns
The strong reference count.

◆ upgrade()

template<typename T >
auto alloc::rc::Weak< T >::upgrade ( ) const -> Option<Rc<T>>
inline

Attempts to upgrade the Weak pointer to an Rc, returning None if the value has been dropped.

Returns
An Option<Rc<T>> containing the upgraded pointer, or None.

◆ weak_count()

template<typename T >
auto alloc::rc::Weak< T >::weak_count ( ) const -> usize
inline

Returns the number of Weak pointers to the same allocation.

Returns
The weak reference count (excluding the implicit weak held by strong pointers).

The documentation for this class was generated from the following file: