diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-01-21 22:03:18 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-01-21 22:03:18 +0100 |
| commit | 9474c74fb6eec4e84ecf26b950c0e27c7cf5f448 (patch) | |
| tree | f2fe482fbfa3b345238e864dfdd2a30b6c819772 /library/std/src | |
| parent | ab19d4a515366ab68b73af3f9a55db52d5542a06 (diff) | |
| parent | 4de76184aa7b8257d44b7a9abf5f140727c84b48 (diff) | |
| download | rust-9474c74fb6eec4e84ecf26b950c0e27c7cf5f448.tar.gz rust-9474c74fb6eec4e84ecf26b950c0e27c7cf5f448.zip | |
Rollup merge of #93109 - JakobDegen:arc-docs, r=m-ou-se
Improve `Arc` and `Rc` documentation This makes two changes (I can split the PR if necessary, but the changes are pretty small): 1. A bunch of trait implementations claimed to be zero cost; however, they use the `Arc<T>: From<Box<T>>` impl which is definitely not free, especially for large dynamically sized `T`. 2. The code in deferred initialization examples unnecessarily used excessive amounts of `unsafe`. This has been reduced.
Diffstat (limited to 'library/std/src')
| -rw-r--r-- | library/std/src/ffi/c_str.rs | 6 | ||||
| -rw-r--r-- | library/std/src/ffi/os_str.rs | 6 | ||||
| -rw-r--r-- | library/std/src/path.rs | 8 |
3 files changed, 13 insertions, 7 deletions
diff --git a/library/std/src/ffi/c_str.rs b/library/std/src/ffi/c_str.rs index d859bff1a45..66fee2fe548 100644 --- a/library/std/src/ffi/c_str.rs +++ b/library/std/src/ffi/c_str.rs @@ -973,7 +973,8 @@ impl<'a> From<&'a CString> for Cow<'a, CStr> { #[stable(feature = "shared_from_slice2", since = "1.24.0")] impl From<CString> for Arc<CStr> { - /// Converts a [`CString`] into an <code>[Arc]<[CStr]></code> without copying or allocating. + /// Converts a [`CString`] into an <code>[Arc]<[CStr]></code> by moving the [`CString`] + /// data into a new [`Arc`] buffer. #[inline] fn from(s: CString) -> Arc<CStr> { let arc: Arc<[u8]> = Arc::from(s.into_inner()); @@ -992,7 +993,8 @@ impl From<&CStr> for Arc<CStr> { #[stable(feature = "shared_from_slice2", since = "1.24.0")] impl From<CString> for Rc<CStr> { - /// Converts a [`CString`] into an <code>[Rc]<[CStr]></code> without copying or allocating. + /// Converts a [`CString`] into an <code>[Rc]<[CStr]></code> by moving the [`CString`] + /// data into a new [`Arc`] buffer. #[inline] fn from(s: CString) -> Rc<CStr> { let rc: Rc<[u8]> = Rc::from(s.into_inner()); diff --git a/library/std/src/ffi/os_str.rs b/library/std/src/ffi/os_str.rs index 982ad189878..81f72e34d93 100644 --- a/library/std/src/ffi/os_str.rs +++ b/library/std/src/ffi/os_str.rs @@ -989,7 +989,8 @@ impl Clone for Box<OsStr> { #[stable(feature = "shared_from_slice2", since = "1.24.0")] impl From<OsString> for Arc<OsStr> { - /// Converts an [`OsString`] into an <code>[Arc]<[OsStr]></code> without copying or allocating. + /// Converts an [`OsString`] into an <code>[Arc]<[OsStr]></code> by moving the [`OsString`] + /// data into a new [`Arc`] buffer. #[inline] fn from(s: OsString) -> Arc<OsStr> { let arc = s.inner.into_arc(); @@ -1008,7 +1009,8 @@ impl From<&OsStr> for Arc<OsStr> { #[stable(feature = "shared_from_slice2", since = "1.24.0")] impl From<OsString> for Rc<OsStr> { - /// Converts an [`OsString`] into an <code>[Rc]<[OsStr]></code> without copying or allocating. + /// Converts an [`OsString`] into an <code>[Rc]<[OsStr]></code> by moving the [`OsString`] + /// data into a new [`Rc`] buffer. #[inline] fn from(s: OsString) -> Rc<OsStr> { let rc = s.inner.into_rc(); diff --git a/library/std/src/path.rs b/library/std/src/path.rs index f509403fe2e..558333518f1 100644 --- a/library/std/src/path.rs +++ b/library/std/src/path.rs @@ -1766,7 +1766,8 @@ impl<'a> From<Cow<'a, Path>> for PathBuf { #[stable(feature = "shared_from_slice2", since = "1.24.0")] impl From<PathBuf> for Arc<Path> { - /// Converts a [`PathBuf`] into an [`Arc`] by moving the [`PathBuf`] data into a new [`Arc`] buffer. + /// Converts a [`PathBuf`] into an <code>[Arc]<[Path]></code> by moving the [`PathBuf`] data + /// into a new [`Arc`] buffer. #[inline] fn from(s: PathBuf) -> Arc<Path> { let arc: Arc<OsStr> = Arc::from(s.into_os_string()); @@ -1786,7 +1787,8 @@ impl From<&Path> for Arc<Path> { #[stable(feature = "shared_from_slice2", since = "1.24.0")] impl From<PathBuf> for Rc<Path> { - /// Converts a [`PathBuf`] into an [`Rc`] by moving the [`PathBuf`] data into a new `Rc` buffer. + /// Converts a [`PathBuf`] into an <code>[Rc]<[Path]></code> by moving the [`PathBuf`] data into + /// a new [`Rc`] buffer. #[inline] fn from(s: PathBuf) -> Rc<Path> { let rc: Rc<OsStr> = Rc::from(s.into_os_string()); @@ -1796,7 +1798,7 @@ impl From<PathBuf> for Rc<Path> { #[stable(feature = "shared_from_slice2", since = "1.24.0")] impl From<&Path> for Rc<Path> { - /// Converts a [`Path`] into an [`Rc`] by copying the [`Path`] data into a new `Rc` buffer. + /// Converts a [`Path`] into an [`Rc`] by copying the [`Path`] data into a new [`Rc`] buffer. #[inline] fn from(s: &Path) -> Rc<Path> { let rc: Rc<OsStr> = Rc::from(s.as_os_str()); |
