impl From<String> for SharedString
shouldn't unnecessarily clone (Rust)
#6597
Labels
a:tool classes & property system
runtime core classes (SharedVector,SharedString) and property system (mO,bS)
enhancement
New feature or request
The code in v1.8.0 is:
You could:
String::push('\0')
.String::into_raw_parts()
is Nightly-only, useString
'scapacity()
andleak()
withas_mut_ptr()
andlen()
on the returned slice instead.String
'sinto_raw_parts()
andleak()
(and the same ofVec
that are used there) are very similar.SharedVector<u8>
infn from(s: String) -> SharedString
, or add something likefrom_raw_parts()
toSharedVector
(at least withpub(crate)
) and call this.EDIT: It seems the layout of your
SharedVectorInner
would make it necessary to shift the data by the size of theSharedVectorHeader
struct to place it in front of theString
data. This is unfortunate. Wouldn't avoiding the reallocation, if possible, still be desirable? If reallocation would be unavoidable, it should definitely only happen once. So, noString::push()
, but a newSharedVector::from_raw_data_buffer_with_reserve(ptr: ..., len: usize, capacity: usize, additional_reserve: usize)
.The text was updated successfully, but these errors were encountered: