1
0
mirror of https://github.com/rust-lang/rustlings.git synced 2025-03-03 15:02:58 +02:00
2024-04-17 23:34:27 +02:00

18 lines
341 B
Rust

// 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);
}