Skip to content

Commit

Permalink
Auto merge of rust-lang#79275 - integer32llc:doc-style, r=jonas-schie…
Browse files Browse the repository at this point in the history
…vink

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.
  • Loading branch information
bors committed Nov 22, 2020
2 parents 8ca930a + ae17d7d commit 20328b5
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_lint/src/unused.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1152,7 +1152,7 @@ declare_lint! {
/// ```rust
/// #![feature(box_syntax)]
/// fn main() {
/// let a = (box [1,2,3]).len();
/// let a = (box [1, 2, 3]).len();
/// }
/// ```
///
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_lint_defs/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1719,7 +1719,7 @@ declare_lint! {
///
/// impl<T: ?Sized> MyIterator for T where T: Iterator { }
///
/// let x = vec![1,2,3];
/// let x = vec![1, 2, 3];
/// let _ = x.iter().is_sorted();
/// ```
///
Expand Down
2 changes: 1 addition & 1 deletion library/alloc/src/collections/btree/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
/// let mut count: BTreeMap<&str, usize> = BTreeMap::new();
///
/// // count the number of occurrences of letters in the vec
/// for x in vec!["a","b","a","c","a","b"] {
/// for x in vec!["a", "b", "a", "c", "a", "b"] {
/// *count.entry(x).or_insert(0) += 1;
/// }
///
Expand Down
10 changes: 5 additions & 5 deletions library/alloc/src/collections/vec_deque/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1962,7 +1962,7 @@ impl<T> VecDeque<T> {
/// ```
/// use std::collections::VecDeque;
///
/// let mut buf: VecDeque<_> = vec![1,2,3].into_iter().collect();
/// let mut buf: VecDeque<_> = vec![1, 2, 3].into_iter().collect();
/// let buf2 = buf.split_off(1);
/// assert_eq!(buf, [1]);
/// assert_eq!(buf2, [2, 3]);
Expand Down Expand Up @@ -2514,10 +2514,10 @@ impl<T> VecDeque<T> {
/// (3, 1), (1, 2), (2, 3), (4, 5), (5, 8), (3, 13),
/// (1, 21), (2, 34), (4, 55)].into();
///
/// assert_eq!(deque.binary_search_by_key(&13, |&(a,b)| b), Ok(9));
/// assert_eq!(deque.binary_search_by_key(&4, |&(a,b)| b), Err(7));
/// assert_eq!(deque.binary_search_by_key(&100, |&(a,b)| b), Err(13));
/// let r = deque.binary_search_by_key(&1, |&(a,b)| b);
/// assert_eq!(deque.binary_search_by_key(&13, |&(a, b)| b), Ok(9));
/// assert_eq!(deque.binary_search_by_key(&4, |&(a, b)| b), Err(7));
/// assert_eq!(deque.binary_search_by_key(&100, |&(a, b)| b), Err(13));
/// let r = deque.binary_search_by_key(&1, |&(a, b)| b);
/// assert!(matches!(r, Ok(1..=4)));
/// ```
#[unstable(feature = "vecdeque_binary_search", issue = "78021")]
Expand Down
4 changes: 2 additions & 2 deletions library/alloc/src/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,7 @@ impl<T, A: AllocRef> Vec<T, A> {
/// }
/// x.set_len(size);
/// }
/// assert_eq!(&*x, &[0,1,2,3]);
/// assert_eq!(&*x, &[0, 1, 2, 3]);
/// ```
#[stable(feature = "vec_as_ptr", since = "1.37.0")]
#[inline]
Expand Down Expand Up @@ -1594,7 +1594,7 @@ impl<T, A: AllocRef> Vec<T, A> {
/// # Examples
///
/// ```
/// let mut vec = vec![1,2,3];
/// let mut vec = vec![1, 2, 3];
/// let vec2 = vec.split_off(1);
/// assert_eq!(vec, [1]);
/// assert_eq!(vec2, [2, 3]);
Expand Down
6 changes: 3 additions & 3 deletions library/core/src/mem/maybe_uninit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ impl<T> MaybeUninit<T> {
/// use std::mem::MaybeUninit;
///
/// let mut x = MaybeUninit::<Vec<u32>>::uninit();
/// unsafe { x.as_mut_ptr().write(vec![0,1,2]); }
/// unsafe { x.as_mut_ptr().write(vec![0, 1, 2]); }
/// // Create a reference into the `MaybeUninit<T>`. This is okay because we initialized it.
/// let x_vec = unsafe { &*x.as_ptr() };
/// assert_eq!(x_vec.len(), 3);
Expand Down Expand Up @@ -429,7 +429,7 @@ impl<T> MaybeUninit<T> {
/// use std::mem::MaybeUninit;
///
/// let mut x = MaybeUninit::<Vec<u32>>::uninit();
/// unsafe { x.as_mut_ptr().write(vec![0,1,2]); }
/// unsafe { x.as_mut_ptr().write(vec![0, 1, 2]); }
/// // Create a reference into the `MaybeUninit<Vec<u32>>`.
/// // This is okay because we initialized it.
/// let x_vec = unsafe { &mut *x.as_mut_ptr() };
Expand Down Expand Up @@ -565,7 +565,7 @@ impl<T> MaybeUninit<T> {
/// use std::mem::MaybeUninit;
///
/// let mut x = MaybeUninit::<Option<Vec<u32>>>::uninit();
/// x.write(Some(vec![0,1,2]));
/// x.write(Some(vec![0, 1, 2]));
/// let x1 = unsafe { x.assume_init_read() };
/// let x2 = unsafe { x.assume_init_read() };
/// // We now created two copies of the same vector, leading to a double-free ⚠️ when
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/ops/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ pub trait Index<Idx: ?Sized> {
/// each can be indexed mutably and immutably.
///
/// ```
/// use std::ops::{Index,IndexMut};
/// use std::ops::{Index, IndexMut};
///
/// #[derive(Debug)]
/// enum Side {
Expand Down
8 changes: 4 additions & 4 deletions library/core/src/slice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1958,10 +1958,10 @@ impl<T> [T] {
/// (1, 2), (2, 3), (4, 5), (5, 8), (3, 13),
/// (1, 21), (2, 34), (4, 55)];
///
/// assert_eq!(s.binary_search_by_key(&13, |&(a,b)| b), Ok(9));
/// assert_eq!(s.binary_search_by_key(&4, |&(a,b)| b), Err(7));
/// assert_eq!(s.binary_search_by_key(&100, |&(a,b)| b), Err(13));
/// let r = s.binary_search_by_key(&1, |&(a,b)| b);
/// assert_eq!(s.binary_search_by_key(&13, |&(a, b)| b), Ok(9));
/// assert_eq!(s.binary_search_by_key(&4, |&(a, b)| b), Err(7));
/// assert_eq!(s.binary_search_by_key(&100, |&(a, b)| b), Err(13));
/// let r = s.binary_search_by_key(&1, |&(a, b)| b);
/// assert!(match r { Ok(1..=4) => true, _ => false, });
/// ```
#[stable(feature = "slice_binary_search_by_key", since = "1.10.0")]
Expand Down

0 comments on commit 20328b5

Please sign in to comment.