1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use Symbol;

/// A pointer to shared data which uses a bound lifetime to avoid outliving its library.
#[derive(Debug)]
pub struct Data<'a, T>
    where T: 'a {
    data: &'a T,
}

impl <'a, T> Data<'a, T> {
    /// Creates a new [Data](struct.Data.html).
    /// This should only be called within the library.
    pub fn new(data: &'a T) -> Self {
        Data {
            data: data,
        }
    }
}

impl <'a, T> Symbol<&'a T> for Data<'a, T> {
    unsafe fn get(&self) -> &'a T {
        self.data
    }
}