mirror of
https://github.com/rust-lang/rustlings.git
synced 2026-01-12 13:49:19 +00:00
23 lines
452 B
Rust
23 lines
452 B
Rust
// lifetimes3.rs
|
|
//
|
|
// Lifetimes are also needed when structs hold references.
|
|
//
|
|
// Make me compile
|
|
//
|
|
// Execute the command `rustlings hint lifetimes3` if you need
|
|
// hints.
|
|
|
|
// I AM NOT DONE
|
|
|
|
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);
|
|
} |