We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
str::clone_into
1 parent c290e9d commit d5ff4f4Copy full SHA for d5ff4f4
library/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