Struct rust_examples::memory::ExclusiveOwnershipTest[][src]

pub struct ExclusiveOwnershipTest;
Expand description

This test demonstrates that in Rust each allocated memory has exactly one owner. Conversely, there cannot be two owners of the same value and ownership can only be moved around.

Example

struct Data;

fn use_data(_data: &Data) {}

let old_owner = Data;
use_data(&old_owner);

let new_owner = old_owner; // Value has been moved at this point
use_data(&new_owner);

// This is no longer allowed!
use_data(&old_owner);

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.