Struct field_offset::FieldOffset [] [src]

pub struct FieldOffset<T, U>(_, _);

Represents a pointer to a field of type U within the type T

Methods

impl<T, U> FieldOffset<T, U>
[src]

unsafe fn new<F: for<'a> FnOnce(&'a T) -> &'a U>(f: F) -> Self

Construct a field offset via a lambda which returns a reference to the field in question.

The lambda must not access the value passed in.

unsafe fn new_from_offset(offset: usize) -> Self

Construct a field offset directly from a byte offset.

fn apply_ptr<'a>(&self, x: *const T) -> *const U

Apply the field offset to a native pointer.

fn apply_ptr_mut<'a>(&self, x: *mut T) -> *mut U

Apply the field offset to a native mutable pointer.

fn apply<'a>(&self, x: &'a T) -> &'a U

Apply the field offset to a reference.

fn apply_mut<'a>(&self, x: &'a mut T) -> &'a mut U

Apply the field offset to a mutable reference.

fn get_byte_offset(&self) -> usize

Get the raw byte offset for this field offset.

unsafe fn unapply_ptr<'a>(&self, x: *const U) -> *const T

Unapply the field offset to a native pointer.

Warning: very unsafe!

unsafe fn unapply_ptr_mut<'a>(&self, x: *mut U) -> *mut T

Unapply the field offset to a native mutable pointer.

Warning: very unsafe!

unsafe fn unapply<'a>(&self, x: &'a U) -> &'a T

Unapply the field offset to a reference.

Warning: very unsafe!

unsafe fn unapply_mut<'a>(&self, x: &'a mut U) -> &'a mut T

Unapply the field offset to a mutable reference.

Warning: very unsafe!

Trait Implementations

impl<T, U, V> Add<FieldOffset<U, V>> for FieldOffset<T, U>
[src]

Allow chaining pointer-to-members.

Applying the resulting field offset is equivalent to applying the first field offset, then applying the second field offset.

The requirements on the generic type parameters ensure this is a safe operation.

type Output = FieldOffset<T, V>

The resulting type after applying the + operator

fn add(self, other: FieldOffset<U, V>) -> FieldOffset<T, V>

The method for the + operator

impl<T, U> Debug for FieldOffset<T, U>
[src]

The debug implementation prints the byte offset of the field in hexadecimal.

fn fmt(&self, f: &mut Formatter) -> Result<()Error>

Formats the value using the given formatter.

impl<T, U> Copy for FieldOffset<T, U>
[src]

impl<T, U> Clone for FieldOffset<T, U>
[src]

fn clone(&self) -> Self

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)
1.0.0

Performs copy-assignment from source. Read more