Struct rustc_ap_rustc_data_structures::owning_ref::OwningHandle [−][src]
pub struct OwningHandle<O, H> where
O: StableAddress,
H: Deref, { /* fields omitted */ }
Expand description
OwningHandle
is a complement to OwningRef
. Where OwningRef
allows
consumers to pass around an owned object and a dependent reference,
OwningHandle
contains an owned object and a dependent object.
OwningHandle
can encapsulate a RefMut
along with its associated
RefCell
, or an RwLockReadGuard
along with its associated RwLock
.
However, the API is completely generic and there are no restrictions on
what types of owning and dependent objects may be used.
OwningHandle
is created by passing an owner object (which dereferences
to a stable address) along with a callback which receives a pointer to
that stable location. The callback may then dereference the pointer and
mint a dependent object, with the guarantee that the returned object will
not outlive the referent of the pointer.
Since the callback needs to dereference a raw pointer, it requires unsafe
code. To avoid forcing this unsafety on most callers, the ToHandle
trait is
implemented for common data structures. Types that implement ToHandle
can
be wrapped into an OwningHandle
without passing a callback.
Implementations
impl<O, H> OwningHandle<O, H> where
O: StableAddress<Target: ToHandle<Handle = H>>,
H: Deref,
[src]
impl<O, H> OwningHandle<O, H> where
O: StableAddress<Target: ToHandle<Handle = H>>,
H: Deref,
[src]impl<O, H> OwningHandle<O, H> where
O: StableAddress<Target: ToHandleMut<HandleMut = H>>,
H: DerefMut,
[src]
impl<O, H> OwningHandle<O, H> where
O: StableAddress<Target: ToHandleMut<HandleMut = H>>,
H: DerefMut,
[src]impl<O, H> OwningHandle<O, H> where
O: StableAddress,
H: Deref,
[src]
impl<O, H> OwningHandle<O, H> where
O: StableAddress,
H: Deref,
[src]pub fn new_with_fn<F>(o: O, f: F) -> Self where
F: FnOnce(*const O::Target) -> H,
[src]
pub fn new_with_fn<F>(o: O, f: F) -> Self where
F: FnOnce(*const O::Target) -> H,
[src]Creates a new OwningHandle. The provided callback will be invoked with
a pointer to the object owned by o
, and the returned value is stored
as the object to which this OwningHandle
will forward Deref
and
DerefMut
.
pub fn try_new<F, E>(o: O, f: F) -> Result<Self, E> where
F: FnOnce(*const O::Target) -> Result<H, E>,
[src]
pub fn try_new<F, E>(o: O, f: F) -> Result<Self, E> where
F: FnOnce(*const O::Target) -> Result<H, E>,
[src]Creates a new OwningHandle. The provided callback will be invoked with
a pointer to the object owned by o
, and the returned value is stored
as the object to which this OwningHandle
will forward Deref
and
DerefMut
.
Trait Implementations
impl<O, H> Deref for OwningHandle<O, H> where
O: StableAddress,
H: Deref,
[src]
impl<O, H> Deref for OwningHandle<O, H> where
O: StableAddress,
H: Deref,
[src]impl<O, H> DerefMut for OwningHandle<O, H> where
O: StableAddress,
H: DerefMut,
[src]
impl<O, H> DerefMut for OwningHandle<O, H> where
O: StableAddress,
H: DerefMut,
[src]impl<O, H> StableDeref for OwningHandle<O, H> where
O: StableAddress,
H: StableAddress,
[src]
O: StableAddress,
H: StableAddress,
Auto Trait Implementations
impl<O, H> RefUnwindSafe for OwningHandle<O, H> where
H: RefUnwindSafe,
O: RefUnwindSafe,
H: RefUnwindSafe,
O: RefUnwindSafe,
impl<O, H> Send for OwningHandle<O, H> where
H: Send,
O: Send,
H: Send,
O: Send,
impl<O, H> Sync for OwningHandle<O, H> where
H: Sync,
O: Sync,
H: Sync,
O: Sync,
impl<O, H> Unpin for OwningHandle<O, H> where
H: Unpin,
O: Unpin,
H: Unpin,
O: Unpin,
impl<O, H> UnwindSafe for OwningHandle<O, H> where
H: UnwindSafe,
O: UnwindSafe,
H: UnwindSafe,
O: UnwindSafe,
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> Instrument for T
[src]
impl<T> Instrument for T
[src]fn instrument(self, span: Span) -> Instrumented<Self>
[src]
fn instrument(self, span: Span) -> Instrumented<Self>
[src]Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
fn in_current_span(self) -> Instrumented<Self>
[src]
fn in_current_span(self) -> Instrumented<Self>
[src]impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
pub fn vzip(self) -> V
impl<'a, T> Captures<'a> for T where
T: ?Sized,
[src]
T: ?Sized,