File tree Expand file tree Collapse file tree 3 files changed +20
-0
lines changed
Expand file tree Collapse file tree 3 files changed +20
-0
lines changed Original file line number Diff line number Diff line change 3636- implemented ` Stream ` directly for ` Bytes ` with a safe ` iter_offsets ` iterator
3737- added ` pop_back ` and ` pop_front ` helpers and rewrote parser examples
3838- added tests covering ` pop_front ` and ` pop_back `
39+ - added tests covering ` take_prefix ` and ` take_suffix `
3940- removed the Completed Work section from ` INVENTORY.md ` and documented its use
4041- added ` Bytes::try_unwrap_owner ` to reclaim the owner when uniquely held
4142- simplified ` Bytes::try_unwrap_owner ` implementation
Original file line number Diff line number Diff line change 55
66## Desired Functionality
77- Add Kani proofs for winnow view helpers.
8+ - Implement ` ExactSizeIterator ` or ` FusedIterator ` for ` BytesIterOffsets ` to simplify iteration.
89
910## Discovered Issues
1011- None at the moment.
Original file line number Diff line number Diff line change @@ -174,6 +174,24 @@ fn test_pop_back() {
174174 assert_eq ! ( bytes. pop_back( ) , None ) ;
175175}
176176
177+ #[ test]
178+ fn test_take_prefix ( ) {
179+ let mut bytes = Bytes :: from ( b"abcdef" . to_vec ( ) ) ;
180+ let prefix = bytes. take_prefix ( 2 ) . expect ( "prefix" ) ;
181+ assert_eq ! ( prefix. as_ref( ) , b"ab" ) ;
182+ assert_eq ! ( bytes. as_ref( ) , b"cdef" ) ;
183+ assert ! ( bytes. take_prefix( 10 ) . is_none( ) ) ;
184+ }
185+
186+ #[ test]
187+ fn test_take_suffix ( ) {
188+ let mut bytes = Bytes :: from ( b"abcdef" . to_vec ( ) ) ;
189+ let suffix = bytes. take_suffix ( 2 ) . expect ( "suffix" ) ;
190+ assert_eq ! ( suffix. as_ref( ) , b"ef" ) ;
191+ assert_eq ! ( bytes. as_ref( ) , b"abcd" ) ;
192+ assert ! ( bytes. take_suffix( 10 ) . is_none( ) ) ;
193+ }
194+
177195#[ test]
178196fn test_weakbytes_multiple_upgrades ( ) {
179197 let bytes = Bytes :: from ( b"hello" . to_vec ( ) ) ;
You can’t perform that action at this time.
0 commit comments