Skip to content

Commit cd4d9d9

Browse files
committed
Auto merge of #102331 - notriddle:rollup-dmefd2d, r=notriddle
Rollup of 6 pull requests Successful merges: - #102283 (Improve code example for Option::unwrap_or_default) - #102319 (rustdoc: merge CSS `table` rules into `.docblock`) - #102321 ( Rustdoc-Json: List impls for primitives) - #102322 (Document that Display automatically implements ToString) - #102325 (rustdoc: give `.line-number` / `.line-numbers` meaningful names) - #102326 (rustdoc: Update doc comment for splitn_mut to include mutable in the …) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents f3a6fbf + 7381d7d commit cd4d9d9

File tree

23 files changed

+116
-70
lines changed

23 files changed

+116
-70
lines changed

library/core/src/fmt/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,12 +709,19 @@ pub use macros::Debug;
709709

710710
/// Format trait for an empty format, `{}`.
711711
///
712+
/// Implementing this trait for a type will automatically implement the
713+
/// [`ToString`][tostring] trait for the type, allowing the usage
714+
/// of the [`.to_string()`][tostring_function] method. Prefer implementing
715+
/// the `Display` trait for a type, rather than [`ToString`][tostring].
716+
///
712717
/// `Display` is similar to [`Debug`], but `Display` is for user-facing
713718
/// output, and so cannot be derived.
714719
///
715720
/// For more information on formatters, see [the module-level documentation][module].
716721
///
717722
/// [module]: ../../std/fmt/index.html
723+
/// [tostring]: ../../std/string/trait.ToString.html
724+
/// [tostring_function]: ../../std/string/trait.ToString.html#tymethod.to_string
718725
///
719726
/// # Examples
720727
///

library/core/src/slice/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2076,7 +2076,7 @@ impl<T> [T] {
20762076
SplitN::new(self.split(pred), n)
20772077
}
20782078

2079-
/// Returns an iterator over subslices separated by elements that match
2079+
/// Returns an iterator over mutable subslices separated by elements that match
20802080
/// `pred`, limited to returning at most `n` items. The matched element is
20812081
/// not contained in the subslices.
20822082
///

src/librustdoc/html/sources.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ pub(crate) fn print_src(
274274
) {
275275
let lines = s.lines().count();
276276
let mut line_numbers = Buffer::empty_from(buf);
277-
line_numbers.write_str("<pre class=\"line-numbers\">");
277+
line_numbers.write_str("<pre class=\"src-line-numbers\">");
278278
match source_context {
279279
SourceContext::Standalone => {
280280
for line in 1..=lines {

src/librustdoc/html/static/css/rustdoc.css

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -299,15 +299,6 @@ summary {
299299

300300
/* Fix some style changes due to normalize.css 8 */
301301

302-
td,
303-
th {
304-
padding: 0;
305-
}
306-
307-
table {
308-
border-collapse: collapse;
309-
}
310-
311302
button,
312303
input,
313304
optgroup,
@@ -578,7 +569,7 @@ h2.location a {
578569
position: relative;
579570
}
580571

581-
.example-wrap > pre.line-number {
572+
pre.example-line-numbers {
582573
overflow: initial;
583574
border: 1px solid;
584575
padding: 13px 8px;
@@ -591,15 +582,15 @@ h2.location a {
591582
text-decoration: underline;
592583
}
593584

594-
.line-numbers {
585+
.src-line-numbers {
595586
text-align: right;
596587
}
597-
.rustdoc:not(.source) .example-wrap > pre:not(.line-number) {
588+
.rustdoc:not(.source) .example-wrap > pre:not(.example-line-numbers) {
598589
width: 100%;
599590
overflow-x: auto;
600591
}
601592

602-
.rustdoc:not(.source) .example-wrap > pre.line-numbers {
593+
.rustdoc:not(.source) .example-wrap > pre.src-line-numbers {
603594
width: auto;
604595
overflow-x: visible;
605596
}
@@ -612,14 +603,14 @@ h2.location a {
612603
text-align: center;
613604
}
614605

615-
.content > .example-wrap pre.line-numbers {
606+
.content > .example-wrap pre.src-line-numbers {
616607
position: relative;
617608
-webkit-user-select: none;
618609
-moz-user-select: none;
619610
-ms-user-select: none;
620611
user-select: none;
621612
}
622-
.line-numbers span {
613+
.src-line-numbers span {
623614
cursor: pointer;
624615
}
625616

@@ -695,6 +686,7 @@ pre, .rustdoc.source .example-wrap {
695686
width: calc(100% - 2px);
696687
overflow-x: auto;
697688
display: block;
689+
border-collapse: collapse;
698690
}
699691

700692
.docblock table td {
@@ -2067,7 +2059,7 @@ in storage.js plus the media query with (min-width: 701px)
20672059
padding-bottom: 0;
20682060
}
20692061

2070-
.scraped-example:not(.expanded) .code-wrapper pre.line-numbers {
2062+
.scraped-example:not(.expanded) .code-wrapper pre.src-line-numbers {
20712063
overflow-x: hidden;
20722064
}
20732065

@@ -2113,12 +2105,12 @@ in storage.js plus the media query with (min-width: 701px)
21132105
bottom: 0;
21142106
}
21152107

2116-
.scraped-example .code-wrapper .line-numbers {
2108+
.scraped-example .code-wrapper .src-line-numbers {
21172109
margin: 0;
21182110
padding: 14px 0;
21192111
}
21202112

2121-
.scraped-example .code-wrapper .line-numbers span {
2113+
.scraped-example .code-wrapper .src-line-numbers span {
21222114
padding: 0 14px;
21232115
}
21242116

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ pre, .rustdoc.source .example-wrap {
9393
color: #ff7733;
9494
}
9595

96-
.line-numbers span { color: #5c6773; }
97-
.line-numbers .line-highlighted {
96+
.src-line-numbers span { color: #5c6773; }
97+
.src-line-numbers .line-highlighted {
9898
color: #708090;
9999
background-color: rgba(255, 236, 164, 0.06);
100100
padding-right: 4px;
@@ -171,7 +171,7 @@ details.rustdoc-toggle > summary::before {
171171
color: #788797;
172172
}
173173

174-
.line-numbers :target { background-color: transparent; }
174+
.src-line-numbers :target { background-color: transparent; }
175175

176176
/* Code highlighting */
177177
pre.rust .number, pre.rust .string { color: #b8cc52; }
@@ -190,7 +190,7 @@ pre.rust .attribute {
190190
color: #e6e1cf;
191191
}
192192

193-
.example-wrap > pre.line-number {
193+
pre.example-line-numbers {
194194
color: #5c67736e;
195195
border: none;
196196
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ input:focus + .slider {
5454
background: #444;
5555
}
5656

57-
.line-numbers span { color: #3B91E2; }
58-
.line-numbers .line-highlighted {
57+
.src-line-numbers span { color: #3B91E2; }
58+
.src-line-numbers .line-highlighted {
5959
background-color: #0a042f !important;
6060
}
6161

@@ -141,7 +141,7 @@ details.rustdoc-toggle > summary::before {
141141
background: none;
142142
}
143143

144-
.line-numbers :target { background-color: transparent; }
144+
.src-line-numbers :target { background-color: transparent; }
145145

146146
/* Code highlighting */
147147
pre.rust .kw { color: #ab8ac1; }
@@ -155,7 +155,7 @@ pre.rust .question-mark {
155155
color: #ff9011;
156156
}
157157

158-
.example-wrap > pre.line-number {
158+
pre.example-line-numbers {
159159
border-color: #4a4949;
160160
}
161161

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ input:focus + .slider {
5353
background-color: #fff;
5454
}
5555

56-
.line-numbers span { color: #c67e2d; }
57-
.line-numbers .line-highlighted {
56+
.src-line-numbers span { color: #c67e2d; }
57+
.src-line-numbers .line-highlighted {
5858
background-color: #FDFFD3 !important;
5959
}
6060

@@ -125,7 +125,7 @@ body.source .example-wrap pre.rust a {
125125
.stab { background: #FFF5D6; border-color: #FFC600; }
126126
.stab.portability > code { background: none; }
127127

128-
.line-numbers :target { background-color: transparent; }
128+
.src-line-numbers :target { background-color: transparent; }
129129

130130
/* Code highlighting */
131131
pre.rust .kw { color: #8959A8; }
@@ -141,7 +141,7 @@ pre.rust .question-mark {
141141
color: #ff9011;
142142
}
143143

144-
.example-wrap > pre.line-number {
144+
pre.example-line-numbers {
145145
border-color: #c7c7c7;
146146
}
147147

src/librustdoc/html/static/js/main.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ function loadCss(cssFileName) {
699699
window.rustdoc_add_line_numbers_to_examples = () => {
700700
onEachLazy(document.getElementsByClassName("rust-example-rendered"), x => {
701701
const parent = x.parentNode;
702-
const line_numbers = parent.querySelectorAll(".line-number");
702+
const line_numbers = parent.querySelectorAll(".example-line-numbers");
703703
if (line_numbers.length > 0) {
704704
return;
705705
}
@@ -709,7 +709,7 @@ function loadCss(cssFileName) {
709709
elems.push(i + 1);
710710
}
711711
const node = document.createElement("pre");
712-
addClass(node, "line-number");
712+
addClass(node, "example-line-numbers");
713713
node.innerHTML = elems.join("\n");
714714
parent.insertBefore(node, x);
715715
});
@@ -718,7 +718,7 @@ function loadCss(cssFileName) {
718718
window.rustdoc_remove_line_numbers_from_examples = () => {
719719
onEachLazy(document.getElementsByClassName("rust-example-rendered"), x => {
720720
const parent = x.parentNode;
721-
const line_numbers = parent.querySelectorAll(".line-number");
721+
const line_numbers = parent.querySelectorAll(".example-line-numbers");
722722
for (const node of line_numbers) {
723723
parent.removeChild(node);
724724
}

src/librustdoc/html/static/js/scrape-examples.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
// Scroll code block to the given code location
1010
function scrollToLoc(elt, loc) {
11-
const lines = elt.querySelector(".line-numbers");
11+
const lines = elt.querySelector(".src-line-numbers");
1212
let scrollOffset;
1313

1414
// If the block is greater than the size of the viewer,

src/librustdoc/html/static/js/source-script.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ function highlightSourceLines(match) {
183183
if (x) {
184184
x.scrollIntoView();
185185
}
186-
onEachLazy(document.getElementsByClassName("line-numbers"), e => {
186+
onEachLazy(document.getElementsByClassName("src-line-numbers"), e => {
187187
onEachLazy(e.getElementsByTagName("span"), i_e => {
188188
removeClass(i_e, "line-highlighted");
189189
});
@@ -245,7 +245,7 @@ window.addEventListener("hashchange", () => {
245245
}
246246
});
247247

248-
onEachLazy(document.getElementsByClassName("line-numbers"), el => {
248+
onEachLazy(document.getElementsByClassName("src-line-numbers"), el => {
249249
el.addEventListener("click", handleSourceHighlight);
250250
});
251251

0 commit comments

Comments
 (0)