summary refs log tree commit diff stats
path: root/tests/ui/example_need_cell.rs
blob: b6e12eb7a2bd8c0f12f9563bab50ab0795118648 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
//! Example of how Rust requires the use of a Cell to build a self-referential
//! struct.
//!
//! NOTE: Also in top-level crate documentation. Keep 'em in sync.

struct MySelfRefStruct<'this> {
    this: &'this MySelfRefStruct<'this>,
}

fn main() {
    let x = MySelfRefStruct { this: &x };
}