Skip to content

Commit

Permalink
Fix IntoVec::into_vec
Browse files Browse the repository at this point in the history
  • Loading branch information
AljoschaMeyer committed Aug 8, 2024
1 parent fd6b73d commit ee7360a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
6 changes: 3 additions & 3 deletions ufotofu/src/common/consumer/into_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,11 @@ mod tests {
#[test]
fn converts_into_vec() {
let mut into_vec = IntoVec::new();
let _ = into_vec.bulk_consume(b"ufotofu");
let _ = into_vec.bulk_consume_full_slice(b"ufotofu");
let _ = into_vec.close(());

let vec = into_vec.into_vec();
assert_eq!(vec.len(), 7);
let v = into_vec.into_vec();
assert_eq!(v, std::vec![117, 102, 111, 116, 111, 102, 117]);
}

// Panic conditions:
Expand Down
10 changes: 6 additions & 4 deletions ufotofu/src/common/consumer/into_vec_fallible.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ impl<T> AsMut<Vec<T>> for IntoVecFallible<T> {

impl<T> Wrapper<Vec<T>> for IntoVecFallible<T> {
fn into_inner(self) -> Vec<T> {
self.v
let IntoVecFallible { mut v, consumed } = self;
v.truncate(consumed);
v
}
}

Expand Down Expand Up @@ -153,11 +155,11 @@ mod tests {
#[test]
fn converts_into_vec() {
let mut into_vec = IntoVecFallible::new();
let _ = into_vec.bulk_consume(b"ufotofu");
let _ = into_vec.bulk_consume_full_slice(b"ufotofu");
let _ = into_vec.close(());

let vec = into_vec.into_vec();
assert_eq!(vec.len(), 7);
let v = into_vec.into_vec();
assert_eq!(v, std::vec![117, 102, 111, 116, 111, 102, 117]);
}

// Panic conditions:
Expand Down

0 comments on commit ee7360a

Please sign in to comment.