Struct repr_offset::get_field_offset::FieldOffsetWithVis [−][src]
A wrapper around a FieldOffset
, with a visibility type parameter
(whether the field is pub or not).
Type parameters
S
: The type that contains the field
V
: The visibility of the field, either IsPrivate
or IsPublic
.
FN
: The name of the field, written using the repr_offset::tstr::TS
macro,
written as TS!(field_name)
.
F
: The type of the field.
A
: The alignment of the field inside of S
, either Aligned
or Unaligned
.
Implementations
impl<S, V, FN, F, A> FieldOffsetWithVis<S, V, FN, F, A>
[src]
pub const unsafe fn new(offset: usize) -> Self
[src]
Constructs this FieldOffsetWithVis
from the offset
(in bytes) of a field.
Safety
This method has a superset of the safety requirements of FieldOffset::new
.
The V
type parameter must be:
-
IsPublic
: When the field ispub
. -
IsPrivate
: When the field has the default (private) visibility, or has a visibility smaller or equal topub(crate)
.
The FN
type parameter must be the name of the field using the
repr_offset::tstr::TS
macro,
eg: TS!(foo)
for the foo
field.
pub const unsafe fn from_fieldoffset(offset: FieldOffset<S, F, A>) -> Self
[src]
Constructs this FieldOffsetWithVis
from offset
.
Safety
The V
type parameter must be:
-
IsPublic
: When the field ispub
. -
IsPrivate
: When the field has the default (private) visibility, or has a visibility smaller or equal topub(crate)
.
The FN
type parameter must be the name of the field using the
repr_offset::tstr::TS
macro,
eg: TS!(foo)
for the foo
field.
impl<FN, S, F, A> FieldOffsetWithVis<S, IsPublic, FN, F, A>
[src]
pub const fn to_field_offset(self) -> FieldOffset<S, F, A>
[src]
Unwraps this into a FieldOffset
for a public field.
impl<S, V, FN, F, A> FieldOffsetWithVis<S, V, FN, F, A>
[src]
pub const unsafe fn private_field_offset(self) -> FieldOffset<S, F, A>
[src]
Unwraps this into a FieldOffset
for a possibly private field.
Safety
Because the field may be private, modifying its state could cause undefined behavior, and is only supposed to be done in a context where the field is accessible.
pub const unsafe fn cast_struct<SO>(self) -> FieldOffsetWithVis<SO, V, FN, F, A>
[src]
Casts this FieldOffsetWithVis
to be for a different struct.
This is mostly useful for #[repr(transparent)]
types to delegate to
their single field.
Safety
SO
must contain a field of type S
as its first field in memory,
at offset 0.
Trait Implementations
impl<S, V, FN, F, A> Clone for FieldOffsetWithVis<S, V, FN, F, A>
[src]
fn clone(&self) -> Self
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<S, V, FN, F, A> Copy for FieldOffsetWithVis<S, V, FN, F, A>
[src]
Auto Trait Implementations
impl<S, V, FN, F, A> Send for FieldOffsetWithVis<S, V, FN, F, A>
[src]
impl<S, V, FN, F, A> Sync for FieldOffsetWithVis<S, V, FN, F, A>
[src]
impl<S, V, FN, F, A> Unpin for FieldOffsetWithVis<S, V, FN, F, A>
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<S> ROExtAcc for S
[src]
pub fn f_get<F>(&Self, FieldOffset<S, F, Aligned>) -> &F
[src]
pub fn f_get_mut<F>(&mut Self, FieldOffset<S, F, Aligned>) -> &mut F
[src]
pub fn f_get_ptr<F, A>(&Self, FieldOffset<S, F, A>) -> *const F
[src]
pub fn f_get_mut_ptr<F, A>(&mut Self, FieldOffset<S, F, A>) -> *mut F
[src]
impl<S> ROExtOps<Aligned> for S
[src]
pub fn f_replace<F>(&mut Self, FieldOffset<S, F, Aligned>, F) -> F
[src]
pub fn f_swap<F>(&mut Self, FieldOffset<S, F, Aligned>, &mut S)
[src]
pub fn f_get_copy<F>(&Self, FieldOffset<S, F, Aligned>) -> F where
F: Copy,
[src]
F: Copy,
impl<S> ROExtOps<Unaligned> for S
[src]
pub fn f_replace<F>(&mut Self, FieldOffset<S, F, Unaligned>, F) -> F
[src]
pub fn f_swap<F>(&mut Self, FieldOffset<S, F, Unaligned>, &mut S)
[src]
pub fn f_get_copy<F>(&Self, FieldOffset<S, F, Unaligned>) -> F where
F: Copy,
[src]
F: Copy,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,