We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a23a77f commit 0653e78Copy full SHA for 0653e78
src/liballoc/boxed.rs
@@ -395,11 +395,9 @@ impl<T: Clone> Clone for Box<T> {
395
#[stable(feature = "box_slice_clone", since = "1.3.0")]
396
impl Clone for Box<str> {
397
fn clone(&self) -> Self {
398
- let len = self.len();
399
- let buf = RawVec::with_capacity(len);
+ let buf: Box<[u8]> = self.as_bytes().into();
400
unsafe {
401
- ptr::copy_nonoverlapping(self.as_ptr(), buf.ptr(), len);
402
- from_boxed_utf8_unchecked(buf.into_box())
+ from_boxed_utf8_unchecked(buf)
403
}
404
405
0 commit comments