8000
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.
str::clone_into
1 parent a451b2a commit 0351c53Copy full SHA for 0351c53
alloc/src/str.rs
@@ -206,15 +206,16 @@ impl BorrowMut<str> for String {
206
#[stable(feature = "rust1", since = "1.0.0")]
207
impl ToOwned for str {
208
type Owned = String;
209
+
210
#[inline]
211
fn to_owned(&self) -> String {
212
unsafe { String::from_utf8_unchecked(self.as_bytes().to_owned()) }
213
}
214
215
+ #[inline]
216
fn clone_into(&self, target: &mut String) {
- let mut b = mem::take(target).into_bytes();
- self.as_bytes().clone_into(&mut b);
217
- *target = unsafe { String::from_utf8_unchecked(b) }
+ target.clear();
218
+ target.push_str(self);
219
220
221
0 commit comments