Struct abi_stable::sabi_trait::RObject
source · #[repr(C)]pub struct RObject<'lt, P, I, V>where
P: GetPointerKind,{ /* private fields */ }
Expand description
RObject
implements ffi-safe trait objects, for a minimal selection of traits.
The main use of RObject<_>
is as the default backend for #[sabi_trait]
generated trait objects.
§Construction
RObject<_>
is how #[sabi_trait]
-based ffi-safe trait objects are implemented,
and there’s no way to construct it separate from those.
§Trait object
RObject<'borrow, Pointer<()>, Interface, VTable>
can be used as a trait object for any combination of
the traits listed below:
§Deconstruction
RObject<_>
can be unwrapped into a concrete type,
within the same dynamic library/executable that constructed it,
using these (fallible) conversion methods:
-
downcast_into
: Unwraps into a pointer toT
.RequiresT: 'static
. -
downcast_as
: Unwraps into a&T
.RequiresT: 'static
. -
downcast_as_mut
: Unwraps into a&mut T
.RequiresT: 'static
.
RObject
can only be converted back if the trait object was constructed to allow it.
Implementations§
source§impl<'lt, P, I, V> RObject<'lt, P, I, V>
impl<'lt, P, I, V> RObject<'lt, P, I, V>
sourcepub unsafe fn with_vtable<OrigPtr>(
ptr: OrigPtr,
vtable: PrefixRef<V>,
) -> RObject<'lt, P, I, V>
pub unsafe fn with_vtable<OrigPtr>( ptr: OrigPtr, vtable: PrefixRef<V>, ) -> RObject<'lt, P, I, V>
Constructs an RObject from a pointer and an extra vtable.
This is mostly intended to be called by #[sabi_trait]
generated trait objects.
§Safety
These are the requirements for the caller:
-
P
must be a pointer to the type that the vtable functions take as the first parameter. -
The vtable must not come from a reborrowed
RObject
(created usingRObject::reborrow
orRObject::reborrow_mut
). -
The vtable must be the
SomeVTableName
of a struct declared with#[derive(StableAbi)] #[sabi(kind(Prefix(prefix_ref= SomeVTableName)))]
. -
The vtable must have
RObjectVtable_Ref
as its first declared field
source§impl<'borr, 'a, I, V> RObject<'borr, RRef<'a, ()>, I, V>
impl<'borr, 'a, I, V> RObject<'borr, RRef<'a, ()>, I, V>
sourcepub const unsafe fn with_vtable_const<T, Downcasting>(
ptr: &'a T,
vtable: PrefixRef<V>,
) -> Selfwhere
T: 'borr,
pub const unsafe fn with_vtable_const<T, Downcasting>(
ptr: &'a T,
vtable: PrefixRef<V>,
) -> Selfwhere
T: 'borr,
This function allows constructing an RObject in a constant/static.
This is mostly intended for #[sabi_trait]
-generated trait objects
§Safety
This has the same safety requirements as RObject::with_vtable
§Example
Because this is intended for #[sabi_trait]
generated trait objects,
this demonstrates how to construct one in a constant.
use abi_stable::sabi_trait::{
doc_examples::ConstExample_CTO,
prelude::TD_Opaque,
};
const EXAMPLE0: ConstExample_CTO<'static, 'static> =
ConstExample_CTO::from_const(&0usize, TD_Opaque);
source§impl<'lt, P, I, V> RObject<'lt, P, I, V>where
P: GetPointerKind,
impl<'lt, P, I, V> RObject<'lt, P, I, V>where
P: GetPointerKind,
sourcepub fn downcast_into<T>(self) -> Result<P::TransmutedPtr, UneraseError<Self>>
pub fn downcast_into<T>(self) -> Result<P::TransmutedPtr, UneraseError<Self>>
Attempts to unerase this trait object into the pointer it was constructed with.
§Errors
This will return an error in any of these conditions:
-
It is called in a dynamic library/binary outside the one from which this RObject was constructed.
-
The trait object wrapping this
RObject
was constructed with aTD_CanDowncast
argument. -
T
is not the concrete type thisRObject<_>
was constructed with.
§Example
use abi_stable::{
sabi_trait::doc_examples::Doer_TO, std_types::RBox,
type_level::downcasting::TD_CanDowncast,
};
let to = || Doer_TO::from_value(5usize, TD_CanDowncast);
// `to.obj` is an RObject
assert_eq!(
to().obj.downcast_into::<usize>().ok(),
Some(RBox::new(5usize))
);
assert_eq!(to().obj.downcast_into::<u8>().ok(), None);
sourcepub fn downcast_as<T>(&self) -> Result<&T, UneraseError<&Self>>
pub fn downcast_as<T>(&self) -> Result<&T, UneraseError<&Self>>
Attempts to unerase this trait object into a reference of the value was constructed with.
§Errors
This will return an error in any of these conditions:
-
It is called in a dynamic library/binary outside the one from which this RObject was constructed.
-
The trait object wrapping this
RObject
was constructed with aTD_CanDowncast
argument. -
T
is not the concrete type thisRObject<_>
was constructed with.
§Example
use abi_stable::{
sabi_trait::doc_examples::Doer_TO, std_types::RArc,
type_level::downcasting::TD_CanDowncast, RMut, RRef,
};
{
let to: Doer_TO<'_, RArc<()>> =
Doer_TO::from_ptr(RArc::new(8usize), TD_CanDowncast);
// `to.obj` is an RObject
assert_eq!(to.obj.downcast_as::<usize>().ok(), Some(&8usize));
assert_eq!(to.obj.downcast_as::<u8>().ok(), None);
}
{
// `#[sabi_trait]` trait objects constructed from `&`
// use `RRef<'_, ()>` instead of `&'_ ()`
// since `&T` can't soundly be transmuted back and forth into `&()`
let to: Doer_TO<'_, RRef<'_, ()>> = Doer_TO::from_ptr(&13usize, TD_CanDowncast);
assert_eq!(to.obj.downcast_as::<usize>().ok(), Some(&13usize));
assert_eq!(to.obj.downcast_as::<u8>().ok(), None);
}
{
let mmut = &mut 21usize;
// `#[sabi_trait]` trait objects constructed from `&mut`
// use `RMut<'_, ()>` instead of `&'_ mut ()`
// since `&mut T` can't soundly be transmuted back and forth into `&mut ()`
let to: Doer_TO<'_, RMut<'_, ()>> = Doer_TO::from_ptr(mmut, TD_CanDowncast);
assert_eq!(to.obj.downcast_as::<usize>().ok(), Some(&21usize));
assert_eq!(to.obj.downcast_as::<u8>().ok(), None);
}
sourcepub fn downcast_as_mut<T>(&mut self) -> Result<&mut T, UneraseError<&mut Self>>
pub fn downcast_as_mut<T>(&mut self) -> Result<&mut T, UneraseError<&mut Self>>
Attempts to unerase this trait object into a mutable reference of the value was constructed with.
§Errors
This will return an error in any of these conditions:
-
It is called in a dynamic library/binary outside the one from which this RObject was constructed.
-
The trait object wrapping this
RObject
was constructed with aTD_CanDowncast
argument. -
T
is not the concrete type thisRObject<_>
was constructed with.
§Example
use abi_stable::{
sabi_trait::doc_examples::Doer_TO, std_types::RBox,
type_level::downcasting::TD_CanDowncast, RMut, RRef,
};
{
let mut to: Doer_TO<'_, RBox<()>> =
Doer_TO::from_value(34usize, TD_CanDowncast);
// `to.obj` is an RObject
assert_eq!(to.obj.downcast_as_mut::<usize>().ok(), Some(&mut 34usize));
assert_eq!(to.obj.downcast_as_mut::<u8>().ok(), None);
}
{
let mmut = &mut 55usize;
// `#[sabi_trait]` trait objects constructed from `&mut`
// use `RMut<'_, ()>` instead of `&'_ mut ()`
// since `&mut T` can't soundly be transmuted back and forth into `&mut ()`
let mut to: Doer_TO<'_, RMut<'_, ()>> = Doer_TO::from_ptr(mmut, TD_CanDowncast);
assert_eq!(to.obj.downcast_as_mut::<usize>().ok(), Some(&mut 55usize));
assert_eq!(to.obj.downcast_as_mut::<u8>().ok(), None);
}
sourcepub unsafe fn unchecked_downcast_into<T>(self) -> P::TransmutedPtr
pub unsafe fn unchecked_downcast_into<T>(self) -> P::TransmutedPtr
Unwraps the RObject<_>
into a pointer to T,
without checking whether T
is the type that the RObject was constructed with.
§Safety
You must check that T
is the type that RObject was constructed
with through other means.
§Example
use abi_stable::{
sabi_trait::doc_examples::Doer_TO, std_types::RBox,
type_level::downcasting::TD_Opaque,
};
let to = || Doer_TO::from_value(5usize, TD_Opaque);
unsafe {
// `to.obj` is an RObject
assert_eq!(
to().obj.unchecked_downcast_into::<usize>(),
RBox::new(5usize)
);
}
sourcepub unsafe fn unchecked_downcast_as<T>(&self) -> &T
pub unsafe fn unchecked_downcast_as<T>(&self) -> &T
Unwraps the RObject<_>
into a reference to T,
without checking whether T
is the type that the RObject was constructed with.
§Safety
You must check that T
is the type that RObject was constructed
with through other means.
§Example
use abi_stable::{
sabi_trait::doc_examples::Doer_TO, std_types::RArc,
type_level::downcasting::TD_Opaque, RMut, RRef,
};
{
let to: Doer_TO<'_, RArc<()>> = Doer_TO::from_ptr(RArc::new(8usize), TD_Opaque);
unsafe {
// `to.obj` is an RObject
assert_eq!(to.obj.unchecked_downcast_as::<usize>(), &8usize);
}
}
{
// `#[sabi_trait]` trait objects constructed from `&`
// use `RRef<'_, ()>` instead of `&'_ ()`
// since `&T` can't soundly be transmuted back and forth into `&()`
let to: Doer_TO<'_, RRef<'_, ()>> = Doer_TO::from_ptr(&13usize, TD_Opaque);
unsafe {
assert_eq!(to.obj.unchecked_downcast_as::<usize>(), &13usize);
}
}
{
let mmut = &mut 21usize;
// `#[sabi_trait]` trait objects constructed from `&mut`
// use `RMut<'_, ()>` instead of `&'_ mut ()`
// since `&mut T` can't soundly be transmuted back and forth into `&mut ()`
let to: Doer_TO<'_, RMut<'_, ()>> = Doer_TO::from_ptr(mmut, TD_Opaque);
unsafe {
assert_eq!(to.obj.unchecked_downcast_as::<usize>(), &21usize);
}
}
sourcepub unsafe fn unchecked_downcast_as_mut<T>(&mut self) -> &mut T
pub unsafe fn unchecked_downcast_as_mut<T>(&mut self) -> &mut T
Unwraps the RObject<_>
into a mutable reference to T,
without checking whether T
is the type that the RObject was constructed with.
§Safety
You must check that T
is the type that RObject was constructed
with through other means.
§Example
use abi_stable::{
sabi_trait::doc_examples::Doer_TO, std_types::RBox,
type_level::downcasting::TD_Opaque, RMut, RRef,
};
{
let mut to: Doer_TO<'_, RBox<()>> = Doer_TO::from_value(34usize, TD_Opaque);
unsafe {
// `to.obj` is an RObject
assert_eq!(to.obj.unchecked_downcast_as_mut::<usize>(), &mut 34usize);
}
}
{
let mmut = &mut 55usize;
// `#[sabi_trait]` trait objects constructed from `&mut`
// use `RMut<'_, ()>` instead of `&'_ mut ()`
// since `&mut T` can't soundly be transmuted back and forth into `&mut ()`
let mut to: Doer_TO<'_, RMut<'_, ()>> = Doer_TO::from_ptr(mmut, TD_Opaque);
unsafe {
assert_eq!(to.obj.unchecked_downcast_as_mut::<usize>(), &mut 55usize);
}
}
source§impl<'lt, P, I, V> RObject<'lt, P, I, V>where
P: GetPointerKind,
I: InterfaceType,
impl<'lt, P, I, V> RObject<'lt, P, I, V>where
P: GetPointerKind,
I: InterfaceType,
sourcepub fn reborrow<'re>(&'re self) -> RObject<'lt, RRef<'re, ()>, I, V>
pub fn reborrow<'re>(&'re self) -> RObject<'lt, RRef<'re, ()>, I, V>
Creates a shared reborrow of this RObject.
This is only callable if RObject
is either Send + Sync
or !Send + !Sync
.
§Example
use abi_stable::{
sabi_trait::doc_examples::Doer_TO, std_types::RBox,
type_level::downcasting::TD_Opaque, RMut, RRef,
};
let mut to: Doer_TO<'_, RBox<()>> = Doer_TO::from_value(13usize, TD_Opaque);
// `to.obj` is an RObject
assert_eq!(debug_string(to.obj.reborrow()), "13");
assert_eq!(debug_string(to.obj.reborrow()), "13");
// `#[sabi_trait]` trait objects have an equivalent `sabi_reborrow` method.
assert_eq!(debug_string(to.sabi_reborrow()), "13");
assert_eq!(debug_string(to.sabi_reborrow()), "13");
fn debug_string<T>(to: T) -> String
where
T: std::fmt::Debug,
{
format!("{:?}", to)
}
sourcepub fn reborrow_mut<'re>(&'re mut self) -> RObject<'lt, RMut<'re, ()>, I, V>
pub fn reborrow_mut<'re>(&'re mut self) -> RObject<'lt, RMut<'re, ()>, I, V>
Creates a mutable reborrow of this RObject.
The reborrowed RObject cannot use these methods:
- RObject::clone
This is only callable if RObject
is either Send + Sync
or !Send + !Sync
.
§Example
use abi_stable::{
sabi_trait::doc_examples::{Doer, Doer_TO},
std_types::RBox,
type_level::downcasting::TD_Opaque,
RMut, RRef,
};
let mut to: Doer_TO<'_, RBox<()>> = Doer_TO::from_value(2usize, TD_Opaque);
// `#[sabi_trait]` trait objects have an equivalent `sabi_reborrow_mut` method,
// which delegate to this method.
assert_eq!(increment(to.sabi_reborrow_mut()).value(), 3);
assert_eq!(increment(to.sabi_reborrow_mut()).value(), 4);
fn increment<T>(mut to: T) -> T
where
T: Doer,
{
to.add_into(1);
to
}
source§impl<'lt, P, I, V> RObject<'lt, P, I, V>where
P: GetPointerKind,
impl<'lt, P, I, V> RObject<'lt, P, I, V>where
P: GetPointerKind,
sourcepub const fn sabi_et_vtable(&self) -> PrefixRef<V>
pub const fn sabi_et_vtable(&self) -> PrefixRef<V>
Gets the vtable.
sourcepub fn sabi_robject_vtable(&self) -> RObjectVtable_Ref<(), P, I>
pub fn sabi_robject_vtable(&self) -> RObjectVtable_Ref<(), P, I>
The vtable common to all #[sabi_trait]
generated trait objects.
sourcepub fn sabi_erased_ref(&self) -> RRef<'_, ErasedObject<()>>
pub fn sabi_erased_ref(&self) -> RRef<'_, ErasedObject<()>>
Gets an RRef
pointing to the erased object.
sourcepub fn sabi_erased_mut(&mut self) -> RMut<'_, ErasedObject<()>>
pub fn sabi_erased_mut(&mut self) -> RMut<'_, ErasedObject<()>>
Gets an RMut
pointing to the erased object.
sourcepub fn sabi_as_rref(&self) -> RRef<'_, ()>
pub fn sabi_as_rref(&self) -> RRef<'_, ()>
Gets an RRef
pointing to the erased object.
sourcepub fn sabi_as_rmut(&mut self) -> RMut<'_, ()>
pub fn sabi_as_rmut(&mut self) -> RMut<'_, ()>
Gets an RMut
pointing to the erased object.
sourcepub fn sabi_with_value<F, R>(self, f: F) -> R
pub fn sabi_with_value<F, R>(self, f: F) -> R
Calls the f
callback with an MovePtr
pointing to the erased object.
Trait Implementations§
source§impl<'lt, P, I, V> Clone for RObject<'lt, P, I, V>
impl<'lt, P, I, V> Clone for RObject<'lt, P, I, V>
Clone is implemented for references and smart pointers,
using GetPointerKind
to decide whether P
is a smart pointer or a reference.
RObject does not implement Clone if P
== &mut ()
:
use abi_stable::{
sabi_trait::{doc_examples::ConstExample_TO, TD_Opaque},
std_types::*,
};
let mut object = ConstExample_TO::from_value(10usize, TD_Opaque);
let borrow = object.sabi_reborrow_mut();
let _ = borrow.clone();
Here is the same example with sabi_reborrow
use abi_stable::{
sabi_trait::{doc_examples::ConstExample_TO, TD_Opaque},
std_types::*,
};
let mut object = ConstExample_TO::from_value(10usize, TD_Opaque);
let borrow = object.sabi_reborrow();
let _ = borrow.clone();
source§impl<P, I, V> Drop for RObject<'_, P, I, V>where
P: GetPointerKind,
impl<P, I, V> Drop for RObject<'_, P, I, V>where
P: GetPointerKind,
source§impl<'lt, P, I, V> Error for RObject<'lt, P, I, V>where
P: AsPtr<PtrTarget = ()>,
I: InterfaceType<Display = Implemented<Display>, Debug = Implemented<Debug>, Error = Implemented<Error>>,
impl<'lt, P, I, V> Error for RObject<'lt, P, I, V>where
P: AsPtr<PtrTarget = ()>,
I: InterfaceType<Display = Implemented<Display>, Debug = Implemented<Debug>, Error = Implemented<Error>>,
1.30.0 · source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · source§fn description(&self) -> &str
fn description(&self) -> &str
source§impl<'lt, P, I, V> GetStaticEquivalent_ for RObject<'lt, P, I, V>where
P: GetPointerKind + __StableAbi,
I: __StableAbi + InterfaceType,
V: __GetStaticEquivalent_ + PrefixStableAbi,
impl<'lt, P, I, V> GetStaticEquivalent_ for RObject<'lt, P, I, V>where
P: GetPointerKind + __StableAbi,
I: __StableAbi + InterfaceType,
V: __GetStaticEquivalent_ + PrefixStableAbi,
source§type StaticEquivalent = _static_RObject<'static, <P as GetStaticEquivalent_>::StaticEquivalent, <I as GetStaticEquivalent_>::StaticEquivalent, <V as GetStaticEquivalent_>::StaticEquivalent>
type StaticEquivalent = _static_RObject<'static, <P as GetStaticEquivalent_>::StaticEquivalent, <I as GetStaticEquivalent_>::StaticEquivalent, <V as GetStaticEquivalent_>::StaticEquivalent>
'static
equivalent of Self
source§impl<'lt, P, I, V> StableAbi for RObject<'lt, P, I, V>where
P: GetPointerKind + __StableAbi,
I: __StableAbi + InterfaceType,
V: __GetStaticEquivalent_ + PrefixStableAbi,
impl<'lt, P, I, V> StableAbi for RObject<'lt, P, I, V>where
P: GetPointerKind + __StableAbi,
I: __StableAbi + InterfaceType,
V: __GetStaticEquivalent_ + PrefixStableAbi,
source§type IsNonZeroType = False
type IsNonZeroType = False
source§const LAYOUT: &'static TypeLayout = _
const LAYOUT: &'static TypeLayout = _
source§const ABI_CONSTS: AbiConsts = _
const ABI_CONSTS: AbiConsts = _
const
-equivalents of the associated types.impl<'lt, P, I, V> Send for RObject<'lt, P, I, V>
impl<'lt, P, I, V> Sync for RObject<'lt, P, I, V>
impl<'lt, P, I, V> Unpin for RObject<'lt, P, I, V>
Auto Trait Implementations§
impl<'lt, P, I, V> Freeze for RObject<'lt, P, I, V>where
P: Freeze,
impl<'lt, P, I, V> RefUnwindSafe for RObject<'lt, P, I, V>where
P: RefUnwindSafe,
V: RefUnwindSafe,
impl<'lt, P, I, V> UnwindSafe for RObject<'lt, P, I, V>where
P: UnwindSafe,
V: RefUnwindSafe,
Blanket Implementations§
source§impl<T> AlignerFor<1> for T
impl<T> AlignerFor<1> for T
source§impl<T> AlignerFor<1024> for T
impl<T> AlignerFor<1024> for T
source§type Aligner = AlignTo1024<T>
type Aligner = AlignTo1024<T>
AlignTo*
type which aligns Self
to ALIGNMENT
.source§impl<T> AlignerFor<128> for T
impl<T> AlignerFor<128> for T
source§type Aligner = AlignTo128<T>
type Aligner = AlignTo128<T>
AlignTo*
type which aligns Self
to ALIGNMENT
.source§impl<T> AlignerFor<16> for T
impl<T> AlignerFor<16> for T
source§impl<T> AlignerFor<16384> for T
impl<T> AlignerFor<16384> for T
source§type Aligner = AlignTo16384<T>
type Aligner = AlignTo16384<T>
AlignTo*
type which aligns Self
to ALIGNMENT
.source§impl<T> AlignerFor<2> for T
impl<T> AlignerFor<2> for T
source§impl<T> AlignerFor<2048> for T
impl<T> AlignerFor<2048> for T
source§type Aligner = AlignTo2048<T>
type Aligner = AlignTo2048<T>
AlignTo*
type which aligns Self
to ALIGNMENT
.source§impl<T> AlignerFor<256> for T
impl<T> AlignerFor<256> for T
source§type Aligner = AlignTo256<T>
type Aligner = AlignTo256<T>
AlignTo*
type which aligns Self
to ALIGNMENT
.source§impl<T> AlignerFor<32> for T
impl<T> AlignerFor<32> for T
source§impl<T> AlignerFor<32768> for T
impl<T> AlignerFor<32768> for T
source§type Aligner = AlignTo32768<T>
type Aligner = AlignTo32768<T>
AlignTo*
type which aligns Self
to ALIGNMENT
.source§impl<T> AlignerFor<4> for T
impl<T> AlignerFor<4> for T
source§impl<T> AlignerFor<4096> for T
impl<T> AlignerFor<4096> for T
source§type Aligner = AlignTo4096<T>
type Aligner = AlignTo4096<T>
AlignTo*
type which aligns Self
to ALIGNMENT
.source§impl<T> AlignerFor<512> for T
impl<T> AlignerFor<512> for T
source§type Aligner = AlignTo512<T>
type Aligner = AlignTo512<T>
AlignTo*
type which aligns Self
to ALIGNMENT
.source§impl<T> AlignerFor<64> for T
impl<T> AlignerFor<64> for T
source§impl<T> AlignerFor<8> for T
impl<T> AlignerFor<8> for T
source§impl<T> AlignerFor<8192> for T
impl<T> AlignerFor<8192> for T
source§type Aligner = AlignTo8192<T>
type Aligner = AlignTo8192<T>
AlignTo*
type which aligns Self
to ALIGNMENT
.source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<'a, T> RCowCompatibleRef<'a> for Twhere
T: Clone + 'a,
impl<'a, T> RCowCompatibleRef<'a> for Twhere
T: Clone + 'a,
source§fn as_c_ref(from: &'a T) -> <T as RCowCompatibleRef<'a>>::RefC
fn as_c_ref(from: &'a T) -> <T as RCowCompatibleRef<'a>>::RefC
source§fn as_rust_ref(from: <T as RCowCompatibleRef<'a>>::RefC) -> &'a T
fn as_rust_ref(from: <T as RCowCompatibleRef<'a>>::RefC) -> &'a T
source§impl<S> ROExtAcc for S
impl<S> ROExtAcc for S
source§fn f_get<F>(&self, offset: FieldOffset<S, F, Aligned>) -> &F
fn f_get<F>(&self, offset: FieldOffset<S, F, Aligned>) -> &F
offset
. Read moresource§fn f_get_mut<F>(&mut self, offset: FieldOffset<S, F, Aligned>) -> &mut F
fn f_get_mut<F>(&mut self, offset: FieldOffset<S, F, Aligned>) -> &mut F
offset
. Read moresource§fn f_get_ptr<F, A>(&self, offset: FieldOffset<S, F, A>) -> *const F
fn f_get_ptr<F, A>(&self, offset: FieldOffset<S, F, A>) -> *const F
offset
. Read moresource§fn f_get_mut_ptr<F, A>(&mut self, offset: FieldOffset<S, F, A>) -> *mut F
fn f_get_mut_ptr<F, A>(&mut self, offset: FieldOffset<S, F, A>) -> *mut F
offset
. Read moresource§impl<S> ROExtOps<Aligned> for S
impl<S> ROExtOps<Aligned> for S
source§fn f_replace<F>(&mut self, offset: FieldOffset<S, F, Aligned>, value: F) -> F
fn f_replace<F>(&mut self, offset: FieldOffset<S, F, Aligned>, value: F) -> F
offset
) with value
,
returning the previous value of the field. Read moresource§fn f_get_copy<F>(&self, offset: FieldOffset<S, F, Aligned>) -> Fwhere
F: Copy,
fn f_get_copy<F>(&self, offset: FieldOffset<S, F, Aligned>) -> Fwhere
F: Copy,
source§impl<S> ROExtOps<Unaligned> for S
impl<S> ROExtOps<Unaligned> for S
source§fn f_replace<F>(&mut self, offset: FieldOffset<S, F, Unaligned>, value: F) -> F
fn f_replace<F>(&mut self, offset: FieldOffset<S, F, Unaligned>, value: F) -> F
offset
) with value
,
returning the previous value of the field. Read moresource§fn f_get_copy<F>(&self, offset: FieldOffset<S, F, Unaligned>) -> Fwhere
F: Copy,
fn f_get_copy<F>(&self, offset: FieldOffset<S, F, Unaligned>) -> Fwhere
F: Copy,
source§impl<T> SelfOps for Twhere
T: ?Sized,
impl<T> SelfOps for Twhere
T: ?Sized,
source§fn piped<F, U>(self, f: F) -> U
fn piped<F, U>(self, f: F) -> U
source§fn piped_ref<'a, F, U>(&'a self, f: F) -> Uwhere
F: FnOnce(&'a Self) -> U,
fn piped_ref<'a, F, U>(&'a self, f: F) -> Uwhere
F: FnOnce(&'a Self) -> U,
piped
except that the function takes &Self
Useful for functions that take &Self
instead of Self
. Read moresource§fn piped_mut<'a, F, U>(&'a mut self, f: F) -> Uwhere
F: FnOnce(&'a mut Self) -> U,
fn piped_mut<'a, F, U>(&'a mut self, f: F) -> Uwhere
F: FnOnce(&'a mut Self) -> U,
piped
, except that the function takes &mut Self
.
Useful for functions that take &mut Self
instead of Self
.source§fn mutated<F>(self, f: F) -> Self
fn mutated<F>(self, f: F) -> Self
source§fn observe<F>(self, f: F) -> Self
fn observe<F>(self, f: F) -> Self
source§fn as_ref_<T>(&self) -> &T
fn as_ref_<T>(&self) -> &T
AsRef
,
using the turbofish .as_ref_::<_>()
syntax. Read more