@@ -278,7 +278,7 @@ pub use self::{
278
278
} ;
279
279
280
280
#[ unstable( feature = "read_buf" , issue = "78485" ) ]
281
- pub use self :: readbuf:: { BorrowBuf , BorrowCursor } ;
281
+ pub use self :: readbuf:: { BorrowedBuf , BorrowedCursor } ;
282
282
pub ( crate ) use error:: const_io_error;
283
283
284
284
mod buffered;
@@ -362,7 +362,7 @@ pub(crate) fn default_read_to_end<R: Read + ?Sized>(r: &mut R, buf: &mut Vec<u8>
362
362
buf. reserve ( 32 ) ; // buf is full, need more space
363
363
}
364
364
365
- let mut read_buf: BorrowBuf < ' _ > = buf. spare_capacity_mut ( ) . into ( ) ;
365
+ let mut read_buf: BorrowedBuf < ' _ > = buf. spare_capacity_mut ( ) . into ( ) ;
366
366
367
367
// SAFETY: These bytes were initialized but not filled in the previous loop
368
368
unsafe {
@@ -383,7 +383,7 @@ pub(crate) fn default_read_to_end<R: Read + ?Sized>(r: &mut R, buf: &mut Vec<u8>
383
383
// store how much was initialized but not filled
384
384
initialized = cursor. init_ref ( ) . len ( ) ;
385
385
386
- // SAFETY: BorrowBuf 's invariants mean this much memory is initialized.
386
+ // SAFETY: BorrowedBuf 's invariants mean this much memory is initialized.
387
387
unsafe {
388
388
let new_len = read_buf. filled ( ) . len ( ) + buf. len ( ) ;
389
389
buf. set_len ( new_len) ;
@@ -462,7 +462,7 @@ pub(crate) fn default_read_exact<R: Read + ?Sized>(this: &mut R, mut buf: &mut [
462
462
}
463
463
}
464
464
465
- pub ( crate ) fn default_read_buf < F > ( read : F , mut cursor : BorrowCursor < ' _ , ' _ > ) -> Result < ( ) >
465
+ pub ( crate ) fn default_read_buf < F > ( read : F , mut cursor : BorrowedCursor < ' _ , ' _ > ) -> Result < ( ) >
466
466
where
467
467
F : FnOnce ( & mut [ u8 ] ) -> Result < usize > ,
468
468
{
@@ -805,24 +805,23 @@ pub trait Read {
805
805
default_read_exact ( self , buf)
806
806
}
807
807
808
- // TODO naming, if should the method be read_cursor? Or should we change the names of the data structures?
809
808
/// Pull some bytes from this source into the specified buffer.
810
809
///
811
- /// This is equivalent to the [`read`](Read::read) method, except that it is passed a [`BorrowCursor `] rather than `[u8]` to allow use
810
+ /// This is equivalent to the [`read`](Read::read) method, except that it is passed a [`BorrowedCursor `] rather than `[u8]` to allow use
812
811
/// with uninitialized buffers. The new data will be appended to any existing contents of `buf`.
813
812
///
814
813
/// The default implementation delegates to `read`.
815
814
#[ unstable( feature = "read_buf" , issue = "78485" ) ]
816
- fn read_buf ( & mut self , buf : BorrowCursor < ' _ , ' _ > ) -> Result < ( ) > {
815
+ fn read_buf ( & mut self , buf : BorrowedCursor < ' _ , ' _ > ) -> Result < ( ) > {
817
816
default_read_buf ( |b| self . read ( b) , buf)
818
817
}
819
818
820
819
/// Read the exact number of bytes required to fill `cursor`.
821
820
///
822
- /// This is equivalent to the [`read_exact`](Read::read_exact) method, except that it is passed a [`BorrowCursor `] rather than `[u8]` to
821
+ /// This is equivalent to the [`read_exact`](Read::read_exact) method, except that it is passed a [`BorrowedCursor `] rather than `[u8]` to
823
822
/// allow use with uninitialized buffers.
824
823
#[ unstable( feature = "read_buf" , issue = "78485" ) ]
825
- fn read_buf_exact ( & mut self , mut cursor : BorrowCursor < ' _ , ' _ > ) -> Result < ( ) > {
824
+ fn read_buf_exact ( & mut self , mut cursor : BorrowedCursor < ' _ , ' _ > ) -> Result < ( ) > {
826
825
while cursor. capacity ( ) > 0 {
827
826
let prev_written = cursor. written ( ) ;
828
827
match self . read_buf ( cursor. clone ( ) ) {
@@ -2587,7 +2586,7 @@ impl<T: Read> Read for Take<T> {
2587
2586
Ok ( n)
2588
2587
}
2589
2588
2590
- fn read_buf ( & mut self , mut buf : BorrowCursor < ' _ , ' _ > ) -> Result < ( ) > {
2589
+ fn read_buf ( & mut self , mut buf : BorrowedCursor < ' _ , ' _ > ) -> Result < ( ) > {
2591
2590
// Don't call into inner reader at all at EOF because it may still block
2592
2591
if self . limit == 0 {
2593
2592
return Ok ( ( ) ) ;
@@ -2602,7 +2601,7 @@ impl<T: Read> Read for Take<T> {
2602
2601
// SAFETY: no uninit data is written to ibuf
2603
2602
let ibuf = unsafe { & mut buf. as_mut ( ) [ ..limit] } ;
2604
2603
2605
- let mut sliced_buf: BorrowBuf < ' _ > = ibuf. into ( ) ;
2604
+ let mut sliced_buf: BorrowedBuf < ' _ > = ibuf. into ( ) ;
2606
2605
2607
2606
// SAFETY: extra_init bytes of ibuf are known to be initialized
2608
2607
unsafe {
0 commit comments