1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
use ouroboros::self_referencing;
#[cfg(test)]
mod ok_tests;
#[self_referencing]
pub struct BoxAndRef {
data: Box<i32>,
#[borrows(data)]
data_ref: &'this i32,
}
#[self_referencing(chain_hack)]
#[allow(clippy::redundant_allocation)]
pub struct ChainHack {
a: Box<i32>,
#[borrows(a)]
b: Box<&'this i32>,
#[borrows(b)]
c: Box<&'this i32>,
}
#[self_referencing]
pub struct DocumentationExample {
int_data: Box<i32>,
float_data: Box<f32>,
#[borrows(int_data)]
int_reference: &'this i32,
#[borrows(mut float_data)]
float_reference: &'this mut f32,
}
#[self_referencing(no_doc)]
pub struct Undocumented {
data: Box<i32>,
#[borrows(data)]
data_ref: &'this i32,
}