Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
- implemented `Stream` directly for `Bytes` with a safe `iter_offsets` iterator
- added `pop_back` and `pop_front` helpers and rewrote parser examples
- added tests covering `pop_front` and `pop_back`
- added tests covering `take_prefix` and `take_suffix`
- removed the Completed Work section from `INVENTORY.md` and documented its use
- added `Bytes::try_unwrap_owner` to reclaim the owner when uniquely held
- simplified `Bytes::try_unwrap_owner` implementation
Expand Down
1 change: 1 addition & 0 deletions INVENTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

## Desired Functionality
- Add Kani proofs for winnow view helpers.
- Implement `ExactSizeIterator` or `FusedIterator` for `BytesIterOffsets` to simplify iteration.

## Discovered Issues
- None at the moment.
18 changes: 18 additions & 0 deletions src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,24 @@ fn test_pop_back() {
assert_eq!(bytes.pop_back(), None);
}

#[test]
fn test_take_prefix() {
let mut bytes = Bytes::from(b"abcdef".to_vec());
let prefix = bytes.take_prefix(2).expect("prefix");
assert_eq!(prefix.as_ref(), b"ab");
assert_eq!(bytes.as_ref(), b"cdef");
assert!(bytes.take_prefix(10).is_none());
}

#[test]
fn test_take_suffix() {
let mut bytes = Bytes::from(b"abcdef".to_vec());
let suffix = bytes.take_suffix(2).expect("suffix");
assert_eq!(suffix.as_ref(), b"ef");
assert_eq!(bytes.as_ref(), b"abcd");
assert!(bytes.take_suffix(10).is_none());
}

#[test]
fn test_weakbytes_multiple_upgrades() {
let bytes = Bytes::from(b"hello".to_vec());
Expand Down