Skip to content

Commit

Permalink
PutBack::put_back now returns the old value
Browse files Browse the repository at this point in the history
Because it does not return `()` anymore, some changes can be necessary to ignore the returned value like here in "tests/quick.rs".
  • Loading branch information
Philippe-Cholet authored and jswrenn committed Feb 19, 2024
1 parent 047ad5d commit b54c4c3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/adaptors/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<I::Item> {
self.top.replace(x)
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/quick.rs
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ quickcheck! {
fn size_put_back(a: Vec<u8>, x: Option<u8>) -> 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)
}
Expand Down

0 comments on commit b54c4c3

Please sign in to comment.