1
Fork 0

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".
This commit is contained in:
Noa 2024-03-08 12:27:24 -06:00
parent bfe762e0ed
commit c0e913fdd7
No known key found for this signature in database
GPG key ID: 7F9F7DB1768C59CF
14 changed files with 134 additions and 24 deletions

View file

@ -1628,6 +1628,10 @@ impl Clone for PathBuf {
PathBuf { 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)