Struct const_field_offset::FieldOffset[][src]

#[repr(transparent)]
pub struct FieldOffset<T, U, PinFlag = NotPinned>(_, _);
Expand description

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

The PinFlag parameter can be set to AllowPin to enable the projection from Pin<&T> to Pin<&U>

Implementations

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

Safety

The lambda must not dereference the provided pointer or access the inner value in any way as it may point to uninitialized memory.

For the returned FieldOffset to be safe to use, the returned pointer must be valid for any instance of T. For example, returning a pointer to a field from an enum with multiple variants will produce a FieldOffset which is unsafe to use.

Construct a field offset directly from a byte offset.

Safety

For the returned FieldOffset to be safe to use, the field offset must be valid for any instance of T. For example, returning the offset to a field from an enum with multiple variants will produce a FieldOffset which is unsafe to use.

Apply the field offset to a native pointer.

Apply the field offset to a native mutable pointer.

Apply the field offset to a reference.

Apply the field offset to a mutable reference.

Get the raw byte offset for this field offset.

Unapply the field offset to a native pointer.

Safety

Warning: very unsafe!

This applies a negative offset to a pointer. If the safety implications of this are not already clear to you, then do not use this method. Also be aware that Rust has stronger aliasing rules than other languages, so it may be UB to dereference the resulting pointer even if it points to a valid location, due to the presence of other live references.

Unapply the field offset to a native mutable pointer.

Safety

Warning: very unsafe!

This applies a negative offset to a pointer. If the safety implications of this are not already clear to you, then do not use this method. Also be aware that Rust has stronger aliasing rules than other languages, so it may be UB to dereference the resulting pointer even if it points to a valid location, due to the presence of other live references.

Unapply the field offset to a reference.

Safety

Warning: very unsafe!

This applies a negative offset to a reference. If the safety implications of this are not already clear to you, then do not use this method. Also be aware that Rust has stronger aliasing rules than other languages, so this method may cause UB even if the resulting reference points to a valid location, due to the presence of other live references.

Unapply the field offset to a mutable reference.

Safety

Warning: very unsafe!

This applies a negative offset to a reference. If the safety implications of this are not already clear to you, then do not use this method. Also be aware that Rust has stronger aliasing rules than other languages, so this method may cause UB even if the resulting reference points to a valid location, due to the presence of other live references.

Convert this offset to an offset that is allowed to go from Pin<&T> to Pin<&U>

Safety

The Pin safety rules for projection must be respected. These rules are explained in the Pin documentation

Remove the AllowPin flag

Construct a field offset directly from a byte offset, which can be projected from a pinned.

Safety

In addition to the safety rules of FieldOffset::new_from_offset, the projection from Pin<&T> to Pin<&U> must also be allowed. The rules are explained in the Pin documentation

Apply the field offset to a pinned reference and return a pinned reference to the field

Apply the field offset to a pinned mutable reference and return a pinned mutable reference to the field

Trait Implementations

The resulting type after applying the + operator.

Performs the + operation. Read more

The resulting type after applying the + operator.

Performs the + operation. Read more

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.

The resulting type after applying the + operator.

Performs the + operation. Read more

The resulting type after applying the + operator.

Performs the + operation. Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

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

Formats the value using the given formatter. Read more

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.