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