Struct rust_examples::memory::AliasingXorMutabilityTest[][src]

pub struct AliasingXorMutabilityTest;
Expand description

This test demonstrates the Aliasing XOR Mutability principle enforced by Rust. This concept states that at any time there can be either

  • multiple shared references
  • or single exclusive reference

Example

#[derive(Debug)]
struct Data;

fn use_data(_data: &Data) {}

let mut data = Data;

let shared = &data;
let exclusive = &mut data;

// Using read-only reference while there exists a reference with exclusive access
use_data(shared);

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.