summaryrefslogtreecommitdiffstats
path: root/third_party/rust/rental/tests/unused.rs
blob: a8962a050cdaa02e5dc428aafcdc44e6df9496fb (plain)
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
use std::rc::Rc;

#[macro_use]
extern crate rental;

pub struct Sample {
    field: i32,
}

rental! {
    mod sample_rental {
        use super::*;

        #[rental]
        pub struct SampleRental {
            sample: Rc<Sample>,
            sref: &'sample i32,
        }
    }
}
use self::sample_rental::SampleRental;

#[test]
fn unused() {
    let sample = Rc::new(Sample { field: 42 });
    let rental = SampleRental::new(sample, |sample_rc| &sample_rc.field);
    rental.rent(|this| println!("{}", this));
}