Skip to content

Commit

Permalink
lifetimes3: lifetimes and structs
Browse files Browse the repository at this point in the history
  • Loading branch information
vhuynhle committed Aug 27, 2023
1 parent 88508b7 commit 6457692
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions exercises/lifetimes/lifetimes3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@
// Execute `rustlings hint lifetimes3` or use the `hint` watch subcommand for a
// hint.

// I AM NOT DONE

struct Book {
author: &str,
title: &str,
struct Book<'a> {
author: &'a str,
title: &'a str,
}

fn main() {
let name = String::from("Jill Smith");
let title = String::from("Fish Flying");
let book = Book { author: &name, title: &title };
let book = Book {
author: &name,
title: &title,
};

println!("{} by {}", book.title, book.author);
}

0 comments on commit 6457692

Please sign in to comment.