1#![cfg_attr(not(feature = "std"), no_std)]
2
3extern crate alloc;
4use alloc::boxed::Box;
5
6use tailvore::self_referencing;
7
8#[cfg(test)]
9mod ok_tests;
10
11pub struct Ext<'this, T, const REV: bool>(&'this Box<T>);
12
13#[self_referencing(pub_extras)]
14pub struct WithConstParam<T: 'static, const REV: bool> {
15 data: core::cell::RefCell<T>,
16 #[borrows(data)]
17 #[not_covariant]
18 dref: Option<Box<Ext<'this, T, REV>>>,
19}
20
21#[self_referencing]
22pub struct DataAndRef {
24 data: i32,
25 #[borrows(data)]
26 data_ref: &'this i32,
27}
28
29#[self_referencing()]
30#[allow(clippy::redundant_allocation)]
31pub struct Chain {
33 a: i32,
34 #[borrows(a)]
35 b: &'this i32,
36 #[borrows(b)]
37 c: &'this i32,
38}
39
40#[self_referencing]
41pub struct DocumentationExample {
43 int_data: i32,
44 float_data: f32,
45 #[borrows(int_data)]
46 int_reference: &'this i32,
47 #[borrows(mut float_data)]
48 float_reference: &'this mut f32,
49}
50
51#[self_referencing(no_doc)]
52pub struct Undocumented {
55 data: Box<i32>,
56 #[borrows(data)]
57 data_ref: &'this i32,
58}
59
60#[self_referencing(pub_extras)]
79pub struct Visibility {
80 private_field: Box<i32>,
81 #[borrows(private_field)]
82 pub public_field: &'this i32,
83 #[borrows(private_field)]
84 pub(crate) pub_crate_field: &'this i32,
85}