Skip to content

Commit d6a28a9

Browse files
committed
Auto merge of #81694 - GuillaumeGomez:rollup-odg6xqi, r=GuillaumeGomez
Rollup of 4 pull requests Successful merges: - #81144 (Fixed formatting typo in map_while docs) - #81573 (Add some links to the cell docs.) - #81679 (Bind all clean::Type variants and remove FIXME) - #81681 (Better styling of "Switch result tab" shortcut) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents b593389 + e57f1cf commit d6a28a9

File tree

6 files changed

+37
-25
lines changed

6 files changed

+37
-25
lines changed

library/core/src/cell.rs

+24-20
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,10 @@
1111
//! mutate it.
1212
//!
1313
//! Shareable mutable containers exist to permit mutability in a controlled manner, even in the
14-
//! presence of aliasing. Both `Cell<T>` and `RefCell<T>` allow doing this in a single-threaded
14+
//! presence of aliasing. Both [`Cell<T>`] and [`RefCell<T>`] allow doing this in a single-threaded
1515
//! way. However, neither `Cell<T>` nor `RefCell<T>` are thread safe (they do not implement
16-
//! `Sync`). If you need to do aliasing and mutation between multiple threads it is possible to
17-
//! use [`Mutex`](../../std/sync/struct.Mutex.html),
18-
//! [`RwLock`](../../std/sync/struct.RwLock.html) or
19-
//! [`atomic`](../../core/sync/atomic/index.html) types.
16+
//! [`Sync`]). If you need to do aliasing and mutation between multiple threads it is possible to
17+
//! use [`Mutex<T>`], [`RwLock<T>`] or [`atomic`] types.
2018
//!
2119
//! Values of the `Cell<T>` and `RefCell<T>` types may be mutated through shared references (i.e.
2220
//! the common `&T` type), whereas most Rust types can only be mutated through unique (`&mut T`)
@@ -28,13 +26,14 @@
2826
//! one must use the `RefCell<T>` type, acquiring a write lock before mutating. `Cell<T>` provides
2927
//! methods to retrieve and change the current interior value:
3028
//!
31-
//! - For types that implement `Copy`, the `get` method retrieves the current interior value.
32-
//! - For types that implement `Default`, the `take` method replaces the current interior value
33-
//! with `Default::default()` and returns the replaced value.
34-
//! - For all types, the `replace` method replaces the current interior value and returns the
35-
//! replaced value and the `into_inner` method consumes the `Cell<T>` and returns the interior
36-
//! value. Additionally, the `set` method replaces the interior value, dropping the replaced
37-
//! value.
29+
//! - For types that implement [`Copy`], the [`get`](Cell::get) method retrieves the current
30+
//! interior value.
31+
//! - For types that implement [`Default`], the [`take`](Cell::take) method replaces the current
32+
//! interior value with [`Default::default()`] and returns the replaced value.
33+
//! - For all types, the [`replace`](Cell::replace) method replaces the current interior value and
34+
//! returns the replaced value and the [`into_inner`](Cell::into_inner) method consumes the
35+
//! `Cell<T>` and returns the interior value. Additionally, the [`set`](Cell::set) method
36+
//! replaces the interior value, dropping the replaced value.
3837
//!
3938
//! `RefCell<T>` uses Rust's lifetimes to implement 'dynamic borrowing', a process whereby one can
4039
//! claim temporary, exclusive, mutable access to the inner value. Borrows for `RefCell<T>`s are
@@ -54,12 +53,12 @@
5453
//!
5554
//! * Introducing mutability 'inside' of something immutable
5655
//! * Implementation details of logically-immutable methods.
57-
//! * Mutating implementations of `Clone`.
56+
//! * Mutating implementations of [`Clone`].
5857
//!
5958
//! ## Introducing mutability 'inside' of something immutable
6059
//!
61-
//! Many shared smart pointer types, including `Rc<T>` and `Arc<T>`, provide containers that can be
62-
//! cloned and shared between multiple parties. Because the contained values may be
60+
//! Many shared smart pointer types, including [`Rc<T>`] and [`Arc<T>`], provide containers that can
61+
//! be cloned and shared between multiple parties. Because the contained values may be
6362
//! multiply-aliased, they can only be borrowed with `&`, not `&mut`. Without cells it would be
6463
//! impossible to mutate data inside of these smart pointers at all.
6564
//!
@@ -91,7 +90,7 @@
9190
//! ```
9291
//!
9392
//! Note that this example uses `Rc<T>` and not `Arc<T>`. `RefCell<T>`s are for single-threaded
94-
//! scenarios. Consider using `RwLock<T>` or `Mutex<T>` if you need shared mutability in a
93+
//! scenarios. Consider using [`RwLock<T>`] or [`Mutex<T>`] if you need shared mutability in a
9594
//! multi-threaded situation.
9695
//!
9796
//! ## Implementation details of logically-immutable methods
@@ -127,10 +126,10 @@
127126
//! ## Mutating implementations of `Clone`
128127
//!
129128
//! This is simply a special - but common - case of the previous: hiding mutability for operations
130-
//! that appear to be immutable. The `clone` method is expected to not change the source value, and
131-
//! is declared to take `&self`, not `&mut self`. Therefore, any mutation that happens in the
132-
//! `clone` method must use cell types. For example, `Rc<T>` maintains its reference counts within a
133-
//! `Cell<T>`.
129+
//! that appear to be immutable. The [`clone`](Clone::clone) method is expected to not change the
130+
//! source value, and is declared to take `&self`, not `&mut self`. Therefore, any mutation that
131+
//! happens in the `clone` method must use cell types. For example, [`Rc<T>`] maintains its
132+
//! reference counts within a `Cell<T>`.
134133
//!
135134
//! ```
136135
//! use std::cell::Cell;
@@ -185,6 +184,11 @@
185184
//! }
186185
//! ```
187186
//!
187+
//! [`Arc<T>`]: ../../std/sync/struct.Arc.html
188+
//! [`Rc<T>`]: ../../std/rc/struct.Rc.html
189+
//! [`RwLock<T>`]: ../../std/sync/struct.RwLock.html
190+
//! [`Mutex<T>`]: ../../std/sync/struct.Mutex.html
191+
//! [`atomic`]: ../../core/sync/atomic/index.html
188192
189193
#![stable(feature = "rust1", since = "1.0.0")]
190194

library/core/src/iter/traits/iterator.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1213,7 +1213,7 @@ pub trait Iterator {
12131213
/// the iteration should stop, but wasn't placed back into the iterator.
12141214
///
12151215
/// Note that unlike [`take_while`] this iterator is **not** fused.
1216-
/// It is also not specified what this iterator returns after the first` None` is returned.
1216+
/// It is also not specified what this iterator returns after the first [`None`] is returned.
12171217
/// If you need fused iterator, use [`fuse`].
12181218
///
12191219
/// [`fuse`]: Iterator::fuse

src/librustdoc/html/render/cache.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,16 @@ fn get_index_type_name(clean_type: &clean::Type, accept_generic: bool) -> Option
214214
clean::Generic(s) if accept_generic => Some(s),
215215
clean::Primitive(ref p) => Some(p.as_sym()),
216216
clean::BorrowedRef { ref type_, .. } => get_index_type_name(type_, accept_generic),
217-
// FIXME: add all from clean::Type.
218-
_ => None,
217+
clean::Generic(_)
218+
| clean::BareFunction(_)
219+
| clean::Tuple(_)
220+
| clean::Slice(_)
221+
| clean::Array(_, _)
222+
| clean::Never
223+
| clean::RawPointer(_, _)
224+
| clean::QPath { .. }
225+
| clean::Infer
226+
| clean::ImplTrait(_) => None,
219227
}
220228
}
221229

src/librustdoc/html/static/main.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2910,7 +2910,7 @@ function defocusSearchBar() {
29102910
["-", "Collapse all sections"],
29112911
].map(x => "<dt>" +
29122912
x[0].split(" ")
2913-
.map((y, index) => (index & 1) === 0 ? "<kbd>" + y + "</kbd>" : y)
2913+
.map((y, index) => (index & 1) === 0 ? "<kbd>" + y + "</kbd>" : " " + y + " ")
29142914
.join("") + "</dt><dd>" + x[1] + "</dd>").join("");
29152915
var div_shortcuts = document.createElement("div");
29162916
addClass(div_shortcuts, "shortcuts");

src/librustdoc/html/static/rustdoc.css

+1
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,7 @@ body.blur > :not(#help) {
798798
float: left;
799799
clear: left;
800800
display: block;
801+
margin-right: 0.5rem;
801802
}
802803
#help > div > span {
803804
text-align: center;

src/librustdoc/html/static/themes/dark.css

-1
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,6 @@ a.test-arrow {
239239
#help dt {
240240
border-color: #bfbfbf;
241241
background: rgba(0,0,0,0);
242-
color: black;
243242
}
244243

245244
.since {

0 commit comments

Comments
 (0)