1
0
Fork 0
mirror of https://github.com/notohh/rustlings.git synced 2024-12-27 12:28:09 -05:00
rustlings/exercises/16_lifetimes/lifetimes3.rs

17 lines
314 B
Rust
Raw Normal View History

2022-07-15 08:01:32 -04:00
// Lifetimes are also needed when structs hold references.
2024-06-27 10:15:53 -04:00
// TODO: Fix the compiler errors about the struct.
2022-07-15 08:01:32 -04:00
struct Book {
author: &str,
title: &str,
}
fn main() {
2024-04-17 17:34:27 -04:00
let book = Book {
2024-06-27 10:15:53 -04:00
author: "George Orwell",
title: "1984",
2024-04-17 17:34:27 -04:00
};
2022-07-15 08:01:32 -04:00
println!("{} by {}", book.title, book.author);
}