File tree 1 file changed +18
-0
lines changed
1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -475,6 +475,24 @@ impl<A: Allocator> Read for VecDeque<u8, A> {
475
475
}
476
476
}
477
477
478
+ /// BufRead is implemented for `VecDeque<u8>` by reading bytes from the front of the `VecDeque`.
479
+ #[ stable( feature = "vecdeque_buf_read" , since = "CURRENT_RUSTC_VERSION" ) ]
480
+ impl < A : Allocator > BufRead for VecDeque < u8 , A > {
481
+ /// Returns the contents of the "front" slice as returned by
482
+ /// [`as_slices`][`VecDeque::as_slices`]. If the contained byte slices of the `VecDeque` are
483
+ /// discontiguous, multiple calls to `fill_buf` will be needed to read the entire content.
484
+ #[ inline]
485
+ fn fill_buf ( & mut self ) -> io:: Result < & [ u8 ] > {
486
+ let ( front, _) = self . as_slices ( ) ;
487
+ Ok ( front)
488
+ }
489
+
490
+ #[ inline]
491
+ fn consume ( & mut self , amt : usize ) {
492
+ self . drain ( ..amt) ;
493
+ }
494
+ }
495
+
478
496
/// Write is implemented for `VecDeque<u8>` by appending to the `VecDeque`, growing it as needed.
479
497
#[ stable( feature = "vecdeque_read_write" , since = "1.63.0" ) ]
480
498
impl < A : Allocator > Write for VecDeque < u8 , A > {
You can’t perform that action at this time.
0 commit comments