Struct situ::Val

source · []
pub struct Val<'a, T: DropRaw + ?Sized> { /* private fields */ }
Expand description

An immovable owned value in borrowed backing memory.

Implementations

Creates a new Val from an exclusively owned pointer.

Safety
  • ptr must be non-null, properly aligned, and valid for reading, writing, and dropping.
  • ptr must not alias any other accessible references for 'a.
  • The value pointed to by ptr must be initialized and immovable.

Creates a new Val from an initialized Slot.

Safety

The value pointed to by slot must be initialized, valid for dropping, and immovable.

Returns a pointer to the referenced value.

Consumes the Val and leaks its value, returning a mutable reference &'a mut T.

This function is mainly useful for data that lives for as long as its backing memory. Dropping the returned reference will cause a memory leak. If this is not acceptable, then the reference should first be wrapped with the Val::new_unchecked function, producing a Val. This Val can then be dropped which will properly destroy T.

Note: this is an associated function, which means that you have to call it as Val::leak(x) instead of x.leak(). This is so that there is no conflict with a method named leak on the value type.

Casts a Val<T> to a Val<U>.

Safety

The value owned by self must be a valid U.

Consumes the Val and returns the value it contained.

Note: this is an associated function, which means that you have to call it as Val::read(this) instead of this.read(). This is so that there is no conflict with a method on the inner type.

Consumes the Val and moves it into the given Slot.

Note: this is an associated function, which means that you have to call it as Val::read_unsized(this, slot) instead of this.read_unsized(slot). This is so that there is no conflict with a method on the inner type.

Panics

Panics if slot does not have the same metadata as this.

Consumes the Val and moves it into the given Slot.

Note: this is an associated function, which means that you have to call it as Val::read_unsized_unchecked(this, slot) instead of this.read_unsized_unchecked(slot). This is so that there is no conflict with a method on the inner type.

Safety

slot must have the same metadata as this.

Forgets the contained value, returning a Slot of the underlying memory.

Drops the contained value, returning a Slot of the underlying memory.

Returns a Ref of the referenced value.

Returns a reborrowed Mut of the referenced value.

Trait Implementations

Formats the value using the given formatter. Read more
The resulting type after dereferencing.
Dereferences the value.
Mutably dereferences the value.
The underlying type that is destructured.
The type of destructuring to perform.
Returns a mutable pointer to the underlying type.
Formats the value using the given formatter. Read more
Executes the destructor for this type. Read more
The target value of this type.
Returns a pointer to this type’s target.
The restructured version of this type.
Restructures a pointer to this type into the target type. Read more

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
Formats the value using the given formatter.
Formats the value using the given formatter.

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type for metadata in pointers and references to Self.
Converts the given value to a String. Read more
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.