File tree Expand file tree Collapse file tree 3 files changed +22
-1
lines changed
Expand file tree Collapse file tree 3 files changed +22
-1
lines changed Original file line number Diff line number Diff line change 3232- documented safety rationale for ` winnow ` integration
3333- implemented ` Stream ` directly for ` Bytes ` with a safe ` iter_offsets ` iterator
3434- added ` pop_back ` and ` pop_front ` helpers and rewrote parser examples
35+ - added tests covering ` pop_front ` and ` pop_back `
3536- removed the Completed Work section from ` INVENTORY.md ` and documented its use
3637- added ` Bytes::try_unwrap_owner ` to reclaim the owner when uniquely held
3738- simplified ` Bytes::try_unwrap_owner ` implementation
Original file line number Diff line number Diff line change 99- ` ByteSource ` implementation for ` VecDeque<u8> ` to support ring buffers.
1010
1111## Discovered Issues
12- - Missing tests for ` pop_front ` and ` pop_back ` helpers .
12+ - None at the moment .
Original file line number Diff line number Diff line change @@ -103,6 +103,26 @@ fn test_slice_to_bytes_unrelated_slice() {
103103 assert ! ( bytes. slice_to_bytes( slice) . is_none( ) ) ;
104104}
105105
106+ #[ test]
107+ fn test_pop_front ( ) {
108+ let mut bytes = Bytes :: from ( b"abc" . to_vec ( ) ) ;
109+ assert_eq ! ( bytes. pop_front( ) , Some ( b'a' ) ) ;
110+ assert_eq ! ( bytes. as_ref( ) , b"bc" ) ;
111+ assert_eq ! ( bytes. pop_front( ) , Some ( b'b' ) ) ;
112+ assert_eq ! ( bytes. pop_front( ) , Some ( b'c' ) ) ;
113+ assert_eq ! ( bytes. pop_front( ) , None ) ;
114+ }
115+
116+ #[ test]
117+ fn test_pop_back ( ) {
118+ let mut bytes = Bytes :: from ( b"abc" . to_vec ( ) ) ;
119+ assert_eq ! ( bytes. pop_back( ) , Some ( b'c' ) ) ;
120+ assert_eq ! ( bytes. as_ref( ) , b"ab" ) ;
121+ assert_eq ! ( bytes. pop_back( ) , Some ( b'b' ) ) ;
122+ assert_eq ! ( bytes. pop_back( ) , Some ( b'a' ) ) ;
123+ assert_eq ! ( bytes. pop_back( ) , None ) ;
124+ }
125+
106126#[ test]
107127fn test_weakbytes_multiple_upgrades ( ) {
108128 let bytes = Bytes :: from ( b"hello" . to_vec ( ) ) ;
You can’t perform that action at this time.
0 commit comments