File tree Expand file tree Collapse file tree 2 files changed +18
-9
lines changed Expand file tree Collapse file tree 2 files changed +18
-9
lines changed Original file line number Diff line number Diff line change @@ -165,10 +165,20 @@ impl Buf {
165165 self . as_slice ( ) . into_rc ( )
166166 }
167167
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`.
169171 #[ 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) ;
172182 }
173183}
174184
Original file line number Diff line number Diff line change @@ -474,13 +474,12 @@ impl Wtf8Buf {
474474 Wtf8Buf { bytes : bytes. into_vec ( ) , is_known_utf8 : false }
475475 }
476476
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`.
478480 #[ 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) ;
484483 }
485484}
486485
You can’t perform that action at this time.
0 commit comments