[−][src]Struct rustc_data_structures::owning_ref::OwningHandle
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
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.
Fields
handle: H
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
_owner: O
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Methods
impl<O, H> OwningHandle<O, H> where
O: StableAddress,
O::Target: ToHandle<Handle = H>,
H: Deref,
[src]
impl<O, H> OwningHandle<O, H> where
O: StableAddress,
O::Target: ToHandle<Handle = H>,
H: Deref,
pub fn new(o: O) -> Self
[src]
pub fn new(o: O) -> Self
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Create a new OwningHandle
for a type that implements ToHandle
. For types
that don't implement ToHandle
, callers may invoke new_with_fn
, which accepts
a callback to perform the conversion.
impl<O, H> OwningHandle<O, H> where
O: StableAddress,
O::Target: ToHandleMut<HandleMut = H>,
H: DerefMut,
[src]
impl<O, H> OwningHandle<O, H> where
O: StableAddress,
O::Target: ToHandleMut<HandleMut = H>,
H: DerefMut,
pub fn new_mut(o: O) -> Self
[src]
pub fn new_mut(o: O) -> Self
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Create a new mutable OwningHandle
for a type that implements ToHandleMut
.
impl<O, H> OwningHandle<O, H> where
O: StableAddress,
H: Deref,
[src]
impl<O, H> OwningHandle<O, H> where
O: StableAddress,
H: Deref,
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,
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Create 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>,
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Create 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,
type Target = H::Target
The resulting type after dereferencing.
fn deref(&self) -> &H::Target
[src]
fn deref(&self) -> &H::Target
Dereferences the value.
impl<O, H> StableAddress for OwningHandle<O, H> where
O: StableAddress,
H: StableAddress,
[src]
impl<O, H> StableAddress for OwningHandle<O, H> where
O: StableAddress,
H: StableAddress,
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,
Auto Trait Implementations
impl<O, H> Send for OwningHandle<O, H> where
H: Send,
O: Send,
impl<O, H> Send for OwningHandle<O, H> where
H: Send,
O: Send,
impl<O, H> Sync for OwningHandle<O, H> where
H: Sync,
O: Sync,
impl<O, H> Sync for OwningHandle<O, H> where
H: Sync,
O: Sync,
Blanket Implementations
impl<T> Erased for T
[src]
impl<T> Erased for T
impl<T> Send for T where
T: ?Sized,
[src]
impl<T> Send for T where
T: ?Sized,
impl<T> Sync for T where
T: ?Sized,
[src]
impl<T> Sync for T where
T: ?Sized,
impl<T> From for T
[src]
impl<T> From for T
impl<T, U> Into for T where
U: From<T>,
[src]
impl<T, U> Into for T where
U: From<T>,
impl<T, U> TryFrom for T where
T: From<U>,
[src]
impl<T, U> TryFrom for T where
T: From<U>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
try_from
)Performs the conversion.
impl<T> Borrow for T where
T: ?Sized,
[src]
impl<T> Borrow for T where
T: ?Sized,
ⓘImportant traits for &'a mut Rfn borrow(&self) -> &T
[src]
fn borrow(&self) -> &T
Immutably borrows from an owned value. Read more
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
try_from
)Performs the conversion.
impl<T> BorrowMut for T where
T: ?Sized,
[src]
impl<T> BorrowMut for T where
T: ?Sized,
ⓘImportant traits for &'a mut Rfn borrow_mut(&mut self) -> &mut T
[src]
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> Any for T where
T: 'static + ?Sized,
[src]
impl<T> Any for T where
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId
[src]
fn get_type_id(&self) -> TypeId
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
Gets the TypeId
of self
. Read more
impl<E> SpecializationError for E
[src]
impl<E> SpecializationError for E
fn not_found<S, T>(trait_name: &'static str, method_name: &'static str) -> E where
T: ?Sized,
[src]
fn not_found<S, T>(trait_name: &'static str, method_name: &'static str) -> E where
T: ?Sized,
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Create an error for a missing method specialization. Defaults to panicking with type, trait & method names. S
is the encoder/decoder state type, T
is the type being encoded/decoded, and the arguments are the names of the trait and method that should've been overridden. Read more
impl<T> Erased for T
impl<T> Erased for T