diff options
| author | bors <bors@rust-lang.org> | 2024-04-17 19:21:44 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-04-17 19:21:44 +0000 |
| commit | d261b5308111fa95427fcfdfd53a8331dd44a2b6 (patch) | |
| tree | 8a985a2ac605d07089841ac906e13601c9d06390 /library/alloc/src/string.rs | |
| parent | 9776f647e67cadaa8c5f56a04c933c72fe27ccbc (diff) | |
| parent | 7c3c2716ff46fb3276c16bdaea226e5a5abc08c0 (diff) | |
| download | rust-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.rs | 4 |
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); } |
