From e95291acdb28fa8d16e189cd3c26495cd5a85e24 Mon Sep 17 00:00:00 2001 From: Peter Goodspeed-Niklaus Date: Fri, 9 Oct 2020 09:29:50 +0200 Subject: [PATCH] book-store: don't use std::mem::replace unnecessarily At some point, std::mem::replace gained the `#[must_use]` attribute: if you don't use the previous value, there's no reason not to just assign to the target directly. This caused a warning to be emitted, which broke our check that no examples generate warnings. This PR fixes that. FWIW, I'm apparently to blame for the original use of mem::replace; at this remove, I have no idea what I was thinking then. --- exercises/book-store/example.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exercises/book-store/example.rs b/exercises/book-store/example.rs index 2c709f6b0..f61db796c 100644 --- a/exercises/book-store/example.rs +++ b/exercises/book-store/example.rs @@ -132,7 +132,7 @@ impl Iterator for DecomposeGroups { let hypothetical_hash = hash_of(&hypothetical); if !self.prev_states.contains(&hypothetical_hash) { self.prev_states.insert(hypothetical_hash); - mem::replace(&mut self.next, Some(hypothetical)); + self.next = Some(hypothetical); return return_value; } } @@ -151,7 +151,7 @@ impl Iterator for DecomposeGroups { hypothetical.push(Group::new_containing(book)); hypothetical.sort(); self.prev_states.insert(hash_of(&hypothetical)); - mem::replace(&mut self.next, Some(hypothetical)); + self.next = Some(hypothetical); } } return_value