File tree Expand file tree Collapse file tree 1 file changed +2
-30
lines changed Expand file tree Collapse file tree 1 file changed +2
-30
lines changed Original file line number Diff line number Diff line change 3737 if let Some ( mut prefix) = self . pre . take ( ) {
3838 // If there are no remaining bytes, let the bytes get dropped.
3939 if !prefix. is_empty ( ) {
40- let copy_len = cmp:: min ( prefix. len ( ) , remaining ( & mut buf) ) ;
41- // TODO: There should be a way to do following two lines cleaner...
42- put_slice ( & mut buf, & prefix[ ..copy_len] ) ;
40+ let copy_len = cmp:: min ( prefix. len ( ) , buf. remaining ( ) ) ;
41+ buf. put_slice ( & prefix[ ..copy_len] ) ;
4342 prefix. advance ( copy_len) ;
4443 // Put back what's left
4544 if !prefix. is_empty ( ) {
5352 }
5453}
5554
56- fn remaining ( cursor : & mut ReadBufCursor < ' _ > ) -> usize {
57- // SAFETY:
58- // We do not uninitialize any set bytes.
59- unsafe { cursor. as_mut ( ) . len ( ) }
60- }
61-
62- // Copied from `ReadBufCursor::put_slice`.
63- // If that becomes public, we could ditch this.
64- fn put_slice ( cursor : & mut ReadBufCursor < ' _ > , slice : & [ u8 ] ) {
65- assert ! (
66- remaining( cursor) >= slice. len( ) ,
67- "buf.len() must fit in remaining()"
68- ) ;
69-
70- let amt = slice. len ( ) ;
71-
72- // SAFETY:
73- // the length is asserted above
74- unsafe {
75- cursor. as_mut ( ) [ ..amt]
76- . as_mut_ptr ( )
77- . cast :: < u8 > ( )
78- . copy_from_nonoverlapping ( slice. as_ptr ( ) , amt) ;
79- cursor. advance ( amt) ;
80- }
81- }
82-
8355impl < T > Write for Rewind < T >
8456where
8557 T : Write + Unpin ,
You can’t perform that action at this time.
0 commit comments