diff options
| author | Noa <coolreader18@gmail.com> | 2024-03-08 12:27:24 -0600 |
|---|---|---|
| committer | Noa <coolreader18@gmail.com> | 2024-03-08 12:27:24 -0600 |
| commit | c0e913fdd7f35b197c6da198c25569fc63244b85 (patch) | |
| tree | fa265bea2162b7b1cdfc3a4933a51b3cc2f1ef60 /library/std/src/ffi | |
| parent | bfe762e0ed2e95041cc12c02c5565c4368f2cc9f (diff) | |
| download | rust-c0e913fdd7f35b197c6da198c25569fc63244b85.tar.gz rust-c0e913fdd7f35b197c6da198c25569fc63244b85.zip | |
Document overrides of `clone_from()`
Specifically, when an override doesn't just forward to an inner type, document the behavior and that it's preferred over simply assigning a clone of source. Also, change instances where the second parameter is "other" to "source".
Diffstat (limited to 'library/std/src/ffi')
| -rw-r--r-- | library/std/src/ffi/os_str.rs | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/library/std/src/ffi/os_str.rs b/library/std/src/ffi/os_str.rs index e44da8e637e..ef7976d2c50 100644 --- a/library/std/src/ffi/os_str.rs +++ b/library/std/src/ffi/os_str.rs @@ -606,6 +606,10 @@ impl Clone for OsString { OsString { inner: self.inner.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. #[inline] fn clone_from(&mut self, source: &Self) { self.inner.clone_from(&source.inner) |
