From 53fa2c22a235c7719b20ff816a390fbe114941e3 Mon Sep 17 00:00:00 2001 From: Charisee Chiw Date: Fri, 10 Feb 2023 10:11:11 -0800 Subject: [PATCH 1/3] Update book-library.md --- src/exercises/day-1/book-library.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/exercises/day-1/book-library.md b/src/exercises/day-1/book-library.md index 34f9b0b1aca3..3623e6ae6787 100644 --- a/src/exercises/day-1/book-library.md +++ b/src/exercises/day-1/book-library.md @@ -18,8 +18,6 @@ Use this to create a library application. Copy the code below to and update the types to make it compile: ```rust,should_panic -// TODO: remove this when you're done with your implementation. -#![allow(unused_variables, dead_code)] {{#include book-library.rs:setup}} From 294bad2febecdecc04c0ea3f0be5e3d0f261ba56 Mon Sep 17 00:00:00 2001 From: Charisee Chiw Date: Fri, 10 Feb 2023 10:15:43 -0800 Subject: [PATCH 2/3] Update book-library.rs --- src/exercises/day-1/book-library.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/exercises/day-1/book-library.rs b/src/exercises/day-1/book-library.rs index 284045aaff4a..1bfc49a0328a 100644 --- a/src/exercises/day-1/book-library.rs +++ b/src/exercises/day-1/book-library.rs @@ -104,8 +104,10 @@ fn main() { let library = Library::new(); //println!("Our library is empty: {}", library.is_empty()); - // - //library.add_book(Book::new("Lord of the Rings", 1954)); + + let favorite_book = Book::new("Lord of the Rings", 1954); + println!("Our favorite book {favorite_book} should go in the library"); + //library.add_book(favorite_book); //library.add_book(Book::new("Alice's Adventures in Wonderland", 1865)); // //library.print_books(); @@ -116,6 +118,9 @@ fn main() { //} // //println!("Our library has {} books", library.len()); + for b in library.books { + println!("{b}"); + } } // ANCHOR_END: main From 66cdc5576d17104a5fbe8013d60e48bbca0de798 Mon Sep 17 00:00:00 2001 From: Martin Geisler Date: Tue, 28 Feb 2023 20:02:11 +0100 Subject: [PATCH 3/3] Apply suggestions from code review Expanding the variable makes it ever-so-slightly easier to read. --- src/exercises/day-1/book-library.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/exercises/day-1/book-library.rs b/src/exercises/day-1/book-library.rs index 1bfc49a0328a..9b6c67b65698 100644 --- a/src/exercises/day-1/book-library.rs +++ b/src/exercises/day-1/book-library.rs @@ -118,8 +118,8 @@ fn main() { //} // //println!("Our library has {} books", library.len()); - for b in library.books { - println!("{b}"); + for book in library.books { + println!("{book}"); } } // ANCHOR_END: main