blob: 9b631cab42838f499d68ca217b74bf364b04adb2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
// Lifetimes are also needed when structs hold references.
struct Book {
author: &str,
title: &str,
}
fn main() {
let name = String::from("Jill Smith");
let title = String::from("Fish Flying");
let book = Book {
author: &name,
title: &title,
};
println!("{} by {}", book.title, book.author);
}
|