Skip to content

Commit 20328b5

Browse files
committed
Auto merge of #79275 - integer32llc:doc-style, r=jonas-schievink
More consistently use spaces after commas in lists in docs This PR changes instances of lists that didn't use spaces after commas, like `vec![1,2,3]`, to `vec![1, 2, 3]` to be more consistent with idiomatic Rust style (the way these were looks strange to me, especially because there are often lists that *do* use spaces after the commas later in the same code block 😬). I noticed one of these in an example in the stdlib docs and went looking for more, but as far as I can see, I'm only changing those spots in user-facing documentation or rustc output, and the changes make no semantic difference.
2 parents 8ca930a + ae17d7d commit 20328b5

File tree

8 files changed

+18
-18
lines changed

8 files changed

+18
-18
lines changed

compiler/rustc_lint/src/unused.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1152,7 +1152,7 @@ declare_lint! {
11521152
/// ```rust
11531153
/// #![feature(box_syntax)]
11541154
/// fn main() {
1155-
/// let a = (box [1,2,3]).len();
1155+
/// let a = (box [1, 2, 3]).len();
11561156
/// }
11571157
/// ```
11581158
///

compiler/rustc_lint_defs/src/builtin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1719,7 +1719,7 @@ declare_lint! {
17191719
///
17201720
/// impl<T: ?Sized> MyIterator for T where T: Iterator { }
17211721
///
1722-
/// let x = vec![1,2,3];
1722+
/// let x = vec![1, 2, 3];
17231723
/// let _ = x.iter().is_sorted();
17241724
/// ```
17251725
///

library/alloc/src/collections/btree/map.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1037,7 +1037,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
10371037
/// let mut count: BTreeMap<&str, usize> = BTreeMap::new();
10381038
///
10391039
/// // count the number of occurrences of letters in the vec
1040-
/// for x in vec!["a","b","a","c","a","b"] {
1040+
/// for x in vec!["a", "b", "a", "c", "a", "b"] {
10411041
/// *count.entry(x).or_insert(0) += 1;
10421042
/// }
10431043
///

library/alloc/src/collections/vec_deque/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1962,7 +1962,7 @@ impl<T> VecDeque<T> {
19621962
/// ```
19631963
/// use std::collections::VecDeque;
19641964
///
1965-
/// let mut buf: VecDeque<_> = vec![1,2,3].into_iter().collect();
1965+
/// let mut buf: VecDeque<_> = vec![1, 2, 3].into_iter().collect();
19661966
/// let buf2 = buf.split_off(1);
19671967
/// assert_eq!(buf, [1]);
19681968
/// assert_eq!(buf2, [2, 3]);
@@ -2514,10 +2514,10 @@ impl<T> VecDeque<T> {
25142514
/// (3, 1), (1, 2), (2, 3), (4, 5), (5, 8), (3, 13),
25152515
/// (1, 21), (2, 34), (4, 55)].into();
25162516
///
2517-
/// assert_eq!(deque.binary_search_by_key(&13, |&(a,b)| b), Ok(9));
2518-
/// assert_eq!(deque.binary_search_by_key(&4, |&(a,b)| b), Err(7));
2519-
/// assert_eq!(deque.binary_search_by_key(&100, |&(a,b)| b), Err(13));
2520-
/// let r = deque.binary_search_by_key(&1, |&(a,b)| b);
2517+
/// assert_eq!(deque.binary_search_by_key(&13, |&(a, b)| b), Ok(9));
2518+
/// assert_eq!(deque.binary_search_by_key(&4, |&(a, b)| b), Err(7));
2519+
/// assert_eq!(deque.binary_search_by_key(&100, |&(a, b)| b), Err(13));
2520+
/// let r = deque.binary_search_by_key(&1, |&(a, b)| b);
25212521
/// assert!(matches!(r, Ok(1..=4)));
25222522
/// ```
25232523
#[unstable(feature = "vecdeque_binary_search", issue = "78021")]

library/alloc/src/vec.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1041,7 +1041,7 @@ impl<T, A: AllocRef> Vec<T, A> {
10411041
/// }
10421042
/// x.set_len(size);
10431043
/// }
1044-
/// assert_eq!(&*x, &[0,1,2,3]);
1044+
/// assert_eq!(&*x, &[0, 1, 2, 3]);
10451045
/// ```
10461046
#[stable(feature = "vec_as_ptr", since = "1.37.0")]
10471047
#[inline]
@@ -1594,7 +1594,7 @@ impl<T, A: AllocRef> Vec<T, A> {
15941594
/// # Examples
15951595
///
15961596
/// ```
1597-
/// let mut vec = vec![1,2,3];
1597+
/// let mut vec = vec![1, 2, 3];
15981598
/// let vec2 = vec.split_off(1);
15991599
/// assert_eq!(vec, [1]);
16001600
/// assert_eq!(vec2, [2, 3]);

library/core/src/mem/maybe_uninit.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ impl<T> MaybeUninit<T> {
392392
/// use std::mem::MaybeUninit;
393393
///
394394
/// let mut x = MaybeUninit::<Vec<u32>>::uninit();
395-
/// unsafe { x.as_mut_ptr().write(vec![0,1,2]); }
395+
/// unsafe { x.as_mut_ptr().write(vec![0, 1, 2]); }
396396
/// // Create a reference into the `MaybeUninit<T>`. This is okay because we initialized it.
397397
/// let x_vec = unsafe { &*x.as_ptr() };
398398
/// assert_eq!(x_vec.len(), 3);
@@ -429,7 +429,7 @@ impl<T> MaybeUninit<T> {
429429
/// use std::mem::MaybeUninit;
430430
///
431431
/// let mut x = MaybeUninit::<Vec<u32>>::uninit();
432-
/// unsafe { x.as_mut_ptr().write(vec![0,1,2]); }
432+
/// unsafe { x.as_mut_ptr().write(vec![0, 1, 2]); }
433433
/// // Create a reference into the `MaybeUninit<Vec<u32>>`.
434434
/// // This is okay because we initialized it.
435435
/// let x_vec = unsafe { &mut *x.as_mut_ptr() };
@@ -565,7 +565,7 @@ impl<T> MaybeUninit<T> {
565565
/// use std::mem::MaybeUninit;
566566
///
567567
/// let mut x = MaybeUninit::<Option<Vec<u32>>>::uninit();
568-
/// x.write(Some(vec![0,1,2]));
568+
/// x.write(Some(vec![0, 1, 2]));
569569
/// let x1 = unsafe { x.assume_init_read() };
570570
/// let x2 = unsafe { x.assume_init_read() };
571571
/// // We now created two copies of the same vector, leading to a double-free ⚠️ when

library/core/src/ops/index.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ pub trait Index<Idx: ?Sized> {
7979
/// each can be indexed mutably and immutably.
8080
///
8181
/// ```
82-
/// use std::ops::{Index,IndexMut};
82+
/// use std::ops::{Index, IndexMut};
8383
///
8484
/// #[derive(Debug)]
8585
/// enum Side {

library/core/src/slice/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1958,10 +1958,10 @@ impl<T> [T] {
19581958
/// (1, 2), (2, 3), (4, 5), (5, 8), (3, 13),
19591959
/// (1, 21), (2, 34), (4, 55)];
19601960
///
1961-
/// assert_eq!(s.binary_search_by_key(&13, |&(a,b)| b), Ok(9));
1962-
/// assert_eq!(s.binary_search_by_key(&4, |&(a,b)| b), Err(7));
1963-
/// assert_eq!(s.binary_search_by_key(&100, |&(a,b)| b), Err(13));
1964-
/// let r = s.binary_search_by_key(&1, |&(a,b)| b);
1961+
/// assert_eq!(s.binary_search_by_key(&13, |&(a, b)| b), Ok(9));
1962+
/// assert_eq!(s.binary_search_by_key(&4, |&(a, b)| b), Err(7));
1963+
/// assert_eq!(s.binary_search_by_key(&100, |&(a, b)| b), Err(13));
1964+
/// let r = s.binary_search_by_key(&1, |&(a, b)| b);
19651965
/// assert!(match r { Ok(1..=4) => true, _ => false, });
19661966
/// ```
19671967
#[stable(feature = "slice_binary_search_by_key", since = "1.10.0")]

0 commit comments

Comments
 (0)