File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -436,6 +436,24 @@ impl<A: Allocator> Read for VecDeque<u8, A> {
436436 }
437437}
438438
439+ /// BufRead is implemented for `VecDeque<u8>` by reading bytes from the front of the `VecDeque`.
440+ #[ stable( feature = "vecdeque_buf_read" , since = "CURRENT_RUSTC_VERSION" ) ]
441+ impl < A : Allocator > BufRead for VecDeque < u8 , A > {
442+ /// Returns the contents of the "front" slice as returned by
443+ /// [`as_slices`][`VecDeque::as_slices`]. If the contained byte slices of the `VecDeque` are
444+ /// discontiguous, multiple calls to `fill_buf` will be needed to read the entire content.
445+ #[ inline]
446+ fn fill_buf ( & mut self ) -> io:: Result < & [ u8 ] > {
447+ let ( front, _) = self . as_slices ( ) ;
448+ Ok ( front)
449+ }
450+
451+ #[ inline]
452+ fn consume ( & mut self , amt : usize ) {
453+ self . drain ( ..amt) ;
454+ }
455+ }
456+
439457/// Write is implemented for `VecDeque<u8>` by appending to the `VecDeque`, growing it as needed.
440458#[ stable( feature = "vecdeque_read_write" , since = "1.63.0" ) ]
441459impl < A : Allocator > Write for VecDeque < u8 , A > {
You can’t perform that action at this time.
0 commit comments