File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -1074,6 +1074,29 @@ unsafe impl BufMut for Vec<u8> {
1074
1074
}
1075
1075
}
1076
1076
1077
+ unsafe impl BufMut for & mut UninitSlice {
1078
+ #[ inline]
1079
+ fn remaining_mut ( & self ) -> usize {
1080
+ self . len ( )
1081
+ }
1082
+
1083
+ #[ inline]
1084
+ fn chunk_mut ( & mut self ) -> & mut UninitSlice {
1085
+ self
1086
+ }
1087
+
1088
+ #[ inline]
1089
+ unsafe fn advance_mut ( & mut self , cnt : usize ) {
1090
+ // Create an empty UninitSlice.
1091
+ let mut empty_slice = [ ] ;
1092
+ let empty_slice = UninitSlice :: from_raw_parts_mut ( empty_slice. as_mut_ptr ( ) , empty_slice. len ( ) ) ;
1093
+
1094
+ // Lifetime dance taken from `impl Write for &mut [u8]`.
1095
+ let ( _, b) = core:: mem:: replace ( self , empty_slice) . split_at_mut ( cnt) ;
1096
+ * self = b;
1097
+ }
1098
+ }
1099
+
1077
1100
// The existence of this function makes the compiler catch if the BufMut
1078
1101
// trait is "object-safe" or not.
1079
1102
fn _assert_trait_object ( _b : & dyn BufMut ) { }
You can’t perform that action at this time.
0 commit comments