#[repr(transparent)]
pub struct Borrowed<'a, T: Abi> { /* private fields */ }
Expand description

A logically borrowed type that still retains the in-memory representation of the underlying type.

Note: this type is normally only used as a field to a struct. For function parameters, the Param type, which builds on top of Borrowed is used.

Borroweds can be thought of much like an Option<&T>. The reason Borrowed must be used instead of Option<&T> is because Borrowed has the same in-memory layout as Option<T>. This is necessary for FFI calls that expect a logically borrowed type that, in-memory, looks like an owned type.

It’s important to note that owned values cannot be turn into Borroweds. After all, Borrowed types are borrowed and not owned. Just as you cannot turn pass a T into function and get a &T back, you cannot pass a T into a function that ultimately expects a Borrowed<'a, T>.

Implementations

Create a new Borrowed value.

Normally, it is not necessary to use this function. Generally, there is a From implementation that allows you to call .into to safely create a Borrowed value.

Create a new null Borrowed value.

Get the abi representation for this param

Note: the return value is only guranteed to be valid for the lifetime of &self

Get an optional reference to the underlying value

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.

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

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 resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. 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.