about summary refs log tree commit diff
path: root/library/alloc/src/string.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-04-17 19:21:44 +0000
committerbors <bors@rust-lang.org>2024-04-17 19:21:44 +0000
commitd261b5308111fa95427fcfdfd53a8331dd44a2b6 (patch)
tree8a985a2ac605d07089841ac906e13601c9d06390 /library/alloc/src/string.rs
parent9776f647e67cadaa8c5f56a04c933c72fe27ccbc (diff)
parent7c3c2716ff46fb3276c16bdaea226e5a5abc08c0 (diff)
downloadrust-d261b5308111fa95427fcfdfd53a8331dd44a2b6.tar.gz
rust-d261b5308111fa95427fcfdfd53a8331dd44a2b6.zip
Auto merge of #3481 - RalfJung:rustup, r=RalfJung
Rustup
Diffstat (limited to 'library/alloc/src/string.rs')
-rw-r--r--library/alloc/src/string.rs4
1 files changed, 4 insertions, 0 deletions
diff --git a/library/alloc/src/string.rs b/library/alloc/src/string.rs
index 5d552c8f15c..082af1447ec 100644
--- a/library/alloc/src/string.rs
+++ b/library/alloc/src/string.rs
@@ -2097,6 +2097,10 @@ impl Clone for String {
         String { vec: self.vec.clone() }
     }
 
+    /// Clones the contents of `source` into `self`.
+    ///
+    /// This method is preferred over simply assigning `source.clone()` to `self`,
+    /// as it avoids reallocation if possible.
     fn clone_from(&mut self, source: &Self) {
         self.vec.clone_from(&source.vec);
     }