Skip to content

Commit b54c4c3

Browse files
Philippe-Choletjswrenn
authored andcommitted
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".
1 parent 047ad5d commit b54c4c3

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/adaptors/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,10 +280,10 @@ where
280280

281281
/// Put back a single value to the front of the iterator.
282282
///
283-
/// If a value is already in the put back slot, it is overwritten.
283+
/// If a value is already in the put back slot, it is returned.
284284
#[inline]
285-
pub fn put_back(&mut self, x: I::Item) {
286-
self.top = Some(x);
285+
pub fn put_back(&mut self, x: I::Item) -> Option<I::Item> {
286+
self.top.replace(x)
287287
}
288288
}
289289

tests/quick.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,7 @@ quickcheck! {
882882
fn size_put_back(a: Vec<u8>, x: Option<u8>) -> bool {
883883
let mut it = put_back(a.into_iter());
884884
if let Some(t) = x {
885-
it.put_back(t)
885+
it.put_back(t);
886886
}
887887
correct_size_hint(it)
888888
}

0 commit comments

Comments
 (0)