@@ -281,7 +281,7 @@ pub use self::{
281281} ;
282282
283283#[ unstable( feature = "read_buf" , issue = "78485" ) ]
284- pub use self :: readbuf:: ReadBuf ;
284+ pub use self :: readbuf:: { ReadBuf , ReadBufRef } ;
285285pub ( crate ) use error:: const_io_error;
286286
287287mod buffered;
@@ -372,7 +372,7 @@ pub(crate) fn default_read_to_end<R: Read + ?Sized>(r: &mut R, buf: &mut Vec<u8>
372372 read_buf. assume_init ( initialized) ;
373373 }
374374
375- match r. read_buf ( & mut read_buf) {
375+ match r. read_buf ( read_buf. borrow ( ) ) {
376376 Ok ( ( ) ) => { }
377377 Err ( e) if e. kind ( ) == ErrorKind :: Interrupted => continue ,
378378 Err ( e) => return Err ( e) ,
@@ -464,7 +464,7 @@ pub(crate) fn default_read_exact<R: Read + ?Sized>(this: &mut R, mut buf: &mut [
464464 }
465465}
466466
467- pub ( crate ) fn default_read_buf < F > ( read : F , buf : & mut ReadBuf < ' _ > ) -> Result < ( ) >
467+ pub ( crate ) fn default_read_buf < F > ( read : F , mut buf : ReadBufRef < ' _ , ' _ > ) -> Result < ( ) >
468468where
469469 F : FnOnce ( & mut [ u8 ] ) -> Result < usize > ,
470470{
@@ -811,7 +811,7 @@ pub trait Read {
811811 ///
812812 /// The default implementation delegates to `read`.
813813 #[ unstable( feature = "read_buf" , issue = "78485" ) ]
814- fn read_buf ( & mut self , buf : & mut ReadBuf < ' _ > ) -> Result < ( ) > {
814+ fn read_buf ( & mut self , buf : ReadBufRef < ' _ , ' _ > ) -> Result < ( ) > {
815815 default_read_buf ( |b| self . read ( b) , buf)
816816 }
817817
@@ -820,10 +820,10 @@ pub trait Read {
820820 /// This is equivalent to the [`read_exact`](Read::read_exact) method, except that it is passed a [`ReadBuf`] rather than `[u8]` to
821821 /// allow use with uninitialized buffers.
822822 #[ unstable( feature = "read_buf" , issue = "78485" ) ]
823- fn read_buf_exact ( & mut self , buf : & mut ReadBuf < ' _ > ) -> Result < ( ) > {
823+ fn read_buf_exact ( & mut self , mut buf : ReadBufRef < ' _ , ' _ > ) -> Result < ( ) > {
824824 while buf. remaining ( ) > 0 {
825825 let prev_filled = buf. filled ( ) . len ( ) ;
826- match self . read_buf ( buf) {
826+ match self . read_buf ( buf. reborrow ( ) ) {
827827 Ok ( ( ) ) => { }
828828 Err ( e) if e. kind ( ) == ErrorKind :: Interrupted => continue ,
829829 Err ( e) => return Err ( e) ,
@@ -2565,7 +2565,7 @@ impl<T: Read> Read for Take<T> {
25652565 Ok ( n)
25662566 }
25672567
2568- fn read_buf ( & mut self , buf : & mut ReadBuf < ' _ > ) -> Result < ( ) > {
2568+ fn read_buf ( & mut self , mut buf : ReadBufRef < ' _ , ' _ > ) -> Result < ( ) > {
25692569 // Don't call into inner reader at all at EOF because it may still block
25702570 if self . limit == 0 {
25712571 return Ok ( ( ) ) ;
@@ -2589,7 +2589,7 @@ impl<T: Read> Read for Take<T> {
25892589 sliced_buf. assume_init ( extra_init) ;
25902590 }
25912591
2592- self . inner . read_buf ( & mut sliced_buf) ?;
2592+ self . inner . read_buf ( sliced_buf. borrow ( ) ) ?;
25932593
25942594 let new_init = sliced_buf. initialized_len ( ) ;
25952595 let filled = sliced_buf. filled_len ( ) ;
@@ -2605,7 +2605,7 @@ impl<T: Read> Read for Take<T> {
26052605
26062606 self . limit -= filled as u64 ;
26072607 } else {
2608- self . inner . read_buf ( buf) ?;
2608+ self . inner . read_buf ( buf. reborrow ( ) ) ?;
26092609
26102610 //inner may unfill
26112611 self . limit -= buf. filled_len ( ) . saturating_sub ( prev_filled) as u64 ;
0 commit comments