2017-01-21から1日間の記事一覧

Lifetimes #2

https://doc.rust-lang.org/book/lifetimes.html を少々。 struct Foo<'a> { x: &'a i32, } fn main() { let y = &5; // this is the same as `let _y = 5; let y = &_y;` let f = Foo { x: y }; println!("{}", f.x); } &5と記載可能な事に驚き。