From 6457692711fe60f6d07359d3d45eb2be1277b987 Mon Sep 17 00:00:00 2001 From: Van Huynh Le Date: Sun, 27 Aug 2023 18:00:09 +0200 Subject: [PATCH] lifetimes3: lifetimes and structs --- exercises/lifetimes/lifetimes3.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/exercises/lifetimes/lifetimes3.rs b/exercises/lifetimes/lifetimes3.rs index 9c59f9c021..88d35071d3 100644 --- a/exercises/lifetimes/lifetimes3.rs +++ b/exercises/lifetimes/lifetimes3.rs @@ -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); }