2 files changed +18
-9
lines changed Original file line number Diff line number Diff line change @@ -165,10 +165,20 @@ impl Buf {
165
165
self . as_slice ( ) . into_rc ( )
166
166
}
167
167
168
- /// Part of a hack to make PathBuf::push/pop more efficient.
168
+ /// More well behaving alternative to allowing outer types
169
+ /// full mutable access to the core `Vec`.
170
+ /// Provides plumbing to core `Vec::truncate`.
169
171
#[ inline]
170
- pub ( crate ) fn as_mut_vec_for_path_buf ( & mut self ) -> & mut Vec < u8 > {
171
- self . inner . as_mut_vec_for_path_buf ( )
172
+ pub ( crate ) fn truncate ( & mut self , len : usize ) {
173
+ self . inner . truncate ( len) ;
174
+ }
175
+
176
+ /// More well behaving alternative to allowing outer types
177
+ /// full mutable access to the core `Vec`.
178
+ /// Provides plumbing to core `Vec::extend_from_slice`.
179
+ #[ inline]
180
+ pub ( crate ) fn extend_from_slice ( & mut self , other : & [ u8 ] ) {
181
+ self . inner . extend_from_slice ( other) ;
172
182
}
173
183
}
174
184
Original file line number Diff line number Diff line change @@ -474,13 +474,12 @@ impl Wtf8Buf {
474
474
Wtf8Buf { bytes : bytes. into_vec ( ) , is_known_utf8 : false }
475
475
}
476
476
477
- /// Part of a hack to make PathBuf::push/pop more efficient.
477
+ /// More well behaving alternative to allowing outer types
478
+ /// full mutable access to the core `Vec`.
479
+ /// Provides plumbing to core `Vec::extend_from_slice`.
478
480
#[ inline]
479
- pub ( crate ) fn as_mut_vec_for_path_buf ( & mut self ) -> & mut Vec < u8 > {
480
- // FIXME: this function should not even exist, as it implies violating Wtf8Buf invariants
481
- // For now, simply assume that is about to happen.
482
- self . is_known_utf8 = false ;
483
- & mut self . bytes
481
+ pub ( crate ) fn extend_from_slice ( & mut self , other : & [ u8 ] ) {
482
+ self . bytes . extend_from_slice ( other) ;
484
483
}
485
484
}
486
485
0 commit comments