Skip to content

Commit a5a7ed6

Browse files
authored
Rollup merge of #64509 - varkor:convert-identity-doc-fixes, r=Centril
Make some adjustments to the documentation for `std::convert::identity` Fixes some extra blank lines and makes some minor tweaks to the wording.
2 parents a31d71f + 18b24b7 commit a5a7ed6

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/libcore/convert.rs

+9-8
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@
4242

4343
use crate::fmt;
4444

45-
/// An identity function.
45+
/// The identity function.
4646
///
4747
/// Two things are important to note about this function:
4848
///
49-
/// - It is not always equivalent to a closure like `|x| x` since the
49+
/// - It is not always equivalent to a closure like `|x| x`, since the
5050
/// closure may coerce `x` into a different type.
5151
///
5252
/// - It moves the input `x` passed to the function.
@@ -56,31 +56,32 @@ use crate::fmt;
5656
///
5757
/// # Examples
5858
///
59-
/// Using `identity` to do nothing among other interesting functions:
59+
/// Using `identity` to do nothing in a sequence of other, interesting,
60+
/// functions:
6061
///
6162
/// ```rust
6263
/// use std::convert::identity;
6364
///
6465
/// fn manipulation(x: u32) -> u32 {
65-
/// // Let's assume that this function does something interesting.
66+
/// // Let's pretend that adding one is an interesting function.
6667
/// x + 1
6768
/// }
6869
///
6970
/// let _arr = &[identity, manipulation];
7071
/// ```
7172
///
72-
/// Using `identity` to get a function that changes nothing in a conditional:
73+
/// Using `identity` as a "do nothing" base case in a conditional:
7374
///
7475
/// ```rust
7576
/// use std::convert::identity;
7677
///
7778
/// # let condition = true;
78-
///
79+
/// #
7980
/// # fn manipulation(x: u32) -> u32 { x + 1 }
80-
///
81+
/// #
8182
/// let do_stuff = if condition { manipulation } else { identity };
8283
///
83-
/// // do more interesting stuff..
84+
/// // Do more interesting stuff...
8485
///
8586
/// let _results = do_stuff(42);
8687
/// ```

0 commit comments

Comments
 (0)