summaryrefslogtreecommitdiff
path: root/rust/graph/graph2.rs
blob: 1e57f1927d493db3d2465912f86177b131bbfcda (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#[derive(Debug)]
struct Node<'a> {
    label: i32,
    next: Option<&'a Node<'a>>,
}


fn main () {
    let mut n = Node { label: 1, next: None };
    unsafe {
        let raw = &mut n as *mut Node;
        (*raw).next = Some(&n);
    }
    println!("{}", n.label);
    println!("{}", n.next.unwrap().label);
    println!("{}", n.next.unwrap().next.unwrap().label);
}