File tree Expand file tree Collapse file tree 3 files changed +4
-16
lines changed Expand file tree Collapse file tree 3 files changed +4
-16
lines changed Original file line number Diff line number Diff line change @@ -227,16 +227,6 @@ impl<'a> BorrowedCursor<'a> {
227227 self . buf . filled - self . start
228228 }
229229
230- /// Returns a shared reference to the initialized portion of the cursor.
231- #[ inline]
232- pub fn init_ref ( & self ) -> & [ u8 ] {
233- // SAFETY: We only slice the initialized part of the buffer, which is always valid
234- unsafe {
235- let buf = self . buf . buf . get_unchecked ( self . buf . filled ..self . buf . init ) ;
236- buf. assume_init_ref ( )
237- }
238- }
239-
240230 /// Returns a mutable reference to the initialized portion of the cursor.
241231 #[ inline]
242232 pub fn init_mut ( & mut self ) -> & mut [ u8 ] {
Original file line number Diff line number Diff line change @@ -61,7 +61,7 @@ fn clear() {
6161 assert_eq ! ( rbuf. filled( ) . len( ) , 0 ) ;
6262 assert_eq ! ( rbuf. unfilled( ) . capacity( ) , 16 ) ;
6363
64- assert_eq ! ( rbuf. unfilled( ) . init_ref ( ) , [ 255 ; 16 ] ) ;
64+ assert_eq ! ( rbuf. unfilled( ) . init_mut ( ) , [ 255 ; 16 ] ) ;
6565}
6666
6767#[ test]
@@ -142,7 +142,6 @@ fn cursor_set_init() {
142142 }
143143
144144 assert_eq ! ( rbuf. init_len( ) , 8 ) ;
145- assert_eq ! ( rbuf. unfilled( ) . init_ref( ) . len( ) , 8 ) ;
146145 assert_eq ! ( rbuf. unfilled( ) . init_mut( ) . len( ) , 8 ) ;
147146 assert_eq ! ( rbuf. unfilled( ) . uninit_mut( ) . len( ) , 8 ) ;
148147 assert_eq ! ( unsafe { rbuf. unfilled( ) . as_mut( ) . len( ) } , 16 ) ;
@@ -160,7 +159,6 @@ fn cursor_set_init() {
160159 }
161160
162161 assert_eq ! ( rbuf. init_len( ) , 12 ) ;
163- assert_eq ! ( rbuf. unfilled( ) . init_ref( ) . len( ) , 8 ) ;
164162 assert_eq ! ( rbuf. unfilled( ) . init_mut( ) . len( ) , 8 ) ;
165163 assert_eq ! ( rbuf. unfilled( ) . uninit_mut( ) . len( ) , 4 ) ;
166164 assert_eq ! ( unsafe { rbuf. unfilled( ) . as_mut( ) . len( ) } , 12 ) ;
Original file line number Diff line number Diff line change @@ -489,7 +489,7 @@ pub(crate) fn default_read_to_end<R: Read + ?Sized>(
489489 }
490490 } ;
491491
492- let unfilled_but_initialized = cursor. init_ref ( ) . len ( ) ;
492+ let unfilled_but_initialized = cursor. init_mut ( ) . len ( ) ;
493493 let bytes_read = cursor. written ( ) ;
494494 let was_fully_initialized = read_buf. init_len ( ) == buf_len;
495495
@@ -3053,7 +3053,7 @@ impl<T: Read> Read for Take<T> {
30533053 // The condition above guarantees that `self.limit` fits in `usize`.
30543054 let limit = self . limit as usize ;
30553055
3056- let extra_init = cmp:: min ( limit, buf. init_ref ( ) . len ( ) ) ;
3056+ let extra_init = cmp:: min ( limit, buf. init_mut ( ) . len ( ) ) ;
30573057
30583058 // SAFETY: no uninit data is written to ibuf
30593059 let ibuf = unsafe { & mut buf. as_mut ( ) [ ..limit] } ;
@@ -3068,7 +3068,7 @@ impl<T: Read> Read for Take<T> {
30683068 let mut cursor = sliced_buf. unfilled ( ) ;
30693069 let result = self . inner . read_buf ( cursor. reborrow ( ) ) ;
30703070
3071- let new_init = cursor. init_ref ( ) . len ( ) ;
3071+ let new_init = cursor. init_mut ( ) . len ( ) ;
30723072 let filled = sliced_buf. len ( ) ;
30733073
30743074 // cursor / sliced_buf / ibuf must drop here
You can’t perform that action at this time.
0 commit comments