sharedlib/symbol/
data.rs

1use Symbol;
2
3/// A pointer to shared data which uses a bound lifetime to avoid outliving its library.
4#[derive(Debug)]
5pub struct Data<'a, T>
6    where T: 'a {
7    data: &'a T,
8}
9
10impl <'a, T> Data<'a, T> {
11    /// Creates a new [Data](struct.Data.html).
12    /// This should only be called within the library.
13    pub fn new(data: &'a T) -> Self {
14        Data {
15            data: data,
16        }
17    }
18}
19
20impl <'a, T> Symbol<&'a T> for Data<'a, T> {
21    unsafe fn get(&self) -> &'a T {
22        self.data
23    }
24}