struct LifetimeStruct<'a> {
    r: &'a str,
}

impl<'a> LifetimeStruct<'a> {
    fn get_ref(&self) -> &'a str {
        self.r
    }
    fn get_self_ref(&self) -> &Self {
        self
    }
}

fn main() {
    let s = "Hello, Rust!".to_string();
    let ls = LifetimeStruct { r: &s };
    println!("LifetimeStructの参照: {}", ls.r);
    println!("LifetimeStructの参照（メソッド経由）: {}", ls.get_ref());
}