1
Fork 0

Rollup merge of #89869 - kpreid:from-doc, r=yaahc

Add documentation to more `From::from` implementations.

For users looking at documentation through IDE popups, this gives them relevant information rather than the generic trait documentation wording “Performs the conversion”. For users reading the documentation for a specific type for any reason, this informs them when the conversion may allocate or copy significant memory versus when it is always a move or cheap copy.

Notes on specific cases:
* The new documentation for `From<T> for T` explains that it is not a conversion at all.
* Also documented `impl<T, U> Into<U> for T where U: From<T>`, the other central blanket implementation of conversion.
* The new documentation for construction of maps and sets from arrays of keys mentions the handling of duplicates. Future work could be to do this for *all* code paths that convert an iterable to a map or set.
* I did not add documentation to conversions of a specific error type to a more general error type.
* I did not add documentation to unstable code.

This change was prepared by searching for the text "From<... for" and so may have missed some cases that for whatever reason did not match. I also looked for `Into` impls but did not find any worth documenting by the above criteria.
This commit is contained in:
Matthias Krüger 2022-02-17 06:29:57 +01:00 committed by GitHub
commit 1cc0ae4cbb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 63 additions and 12 deletions

View file

@ -1277,7 +1277,7 @@ impl fmt::Debug for Stdio {
#[stable(feature = "stdio_from", since = "1.20.0")]
impl From<ChildStdin> for Stdio {
/// Converts a `ChildStdin` into a `Stdio`
/// Converts a [`ChildStdin`] into a [`Stdio`].
///
/// # Examples
///
@ -1306,7 +1306,7 @@ impl From<ChildStdin> for Stdio {
#[stable(feature = "stdio_from", since = "1.20.0")]
impl From<ChildStdout> for Stdio {
/// Converts a `ChildStdout` into a `Stdio`
/// Converts a [`ChildStdout`] into a [`Stdio`].
///
/// # Examples
///
@ -1335,7 +1335,7 @@ impl From<ChildStdout> for Stdio {
#[stable(feature = "stdio_from", since = "1.20.0")]
impl From<ChildStderr> for Stdio {
/// Converts a `ChildStderr` into a `Stdio`
/// Converts a [`ChildStderr`] into a [`Stdio`].
///
/// # Examples
///
@ -1366,7 +1366,7 @@ impl From<ChildStderr> for Stdio {
#[stable(feature = "stdio_from", since = "1.20.0")]
impl From<fs::File> for Stdio {
/// Converts a `File` into a `Stdio`
/// Converts a [`File`](fs::File) into a [`Stdio`].
///
/// # Examples
///