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);