From fd511feac26e7f5968d96542772813d140eb82e0 Mon Sep 17 00:00:00 2001 From: Philippe-Cholet <44676486+Philippe-Cholet@users.noreply.github.com> Date: Mon, 19 Feb 2024 11:31:13 +0100 Subject: [PATCH] `PutBack::put_back` now returns the old value Because it does not return `()` anymore, some changes can be necessary to ignore the returned value like here in "tests/quick.rs". --- src/adaptors/mod.rs | 6 +++--- tests/quick.rs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/adaptors/mod.rs b/src/adaptors/mod.rs index cf9642bc5..191d551da 100644 --- a/src/adaptors/mod.rs +++ b/src/adaptors/mod.rs @@ -280,10 +280,10 @@ where /// Put back a single value to the front of the iterator. /// - /// If a value is already in the put back slot, it is overwritten. + /// If a value is already in the put back slot, it is returned. #[inline] - pub fn put_back(&mut self, x: I::Item) { - self.top = Some(x); + pub fn put_back(&mut self, x: I::Item) -> Option { + self.top.replace(x) } } diff --git a/tests/quick.rs b/tests/quick.rs index b2982a6ef..e345c9813 100644 --- a/tests/quick.rs +++ b/tests/quick.rs @@ -882,7 +882,7 @@ quickcheck! { fn size_put_back(a: Vec, x: Option) -> bool { let mut it = put_back(a.into_iter()); if let Some(t) = x { - it.put_back(t) + it.put_back(t); } correct_size_hint(it) }