File tree 1 file changed +2
-30
lines changed
1 file changed +2
-30
lines changed Original file line number Diff line number Diff line change 37
37
if let Some ( mut prefix) = self . pre . take ( ) {
38
38
// If there are no remaining bytes, let the bytes get dropped.
39
39
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] ) ;
43
42
prefix. advance ( copy_len) ;
44
43
// Put back what's left
45
44
if !prefix. is_empty ( ) {
53
52
}
54
53
}
55
54
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
-
83
55
impl < T > Write for Rewind < T >
84
56
where
85
57
T : Write + Unpin ,
You can’t perform that action at this time.
0 commit comments