Skip to content

Commit e51830b

Browse files
committed
Auto merge of #85757 - GuillaumeGomez:rollup-k8hfhp8, r=GuillaumeGomez
Rollup of 3 pull requests Successful merges: - #85722 (Fix trait methods' toggle) - #85730 (Mention workaround for floats in Iterator::{min, max}) - #85738 (Rename opensbd to openbsd) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents d854c3c + 48706ed commit e51830b

File tree

4 files changed

+47
-10
lines changed

4 files changed

+47
-10
lines changed

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

+26-2
Original file line numberDiff line numberDiff line change
@@ -2568,6 +2568,18 @@ pub trait Iterator {
25682568
/// If several elements are equally maximum, the last element is
25692569
/// returned. If the iterator is empty, [`None`] is returned.
25702570
///
2571+
/// Note that [`f32`]/[`f64`] doesn't implement [`Ord`] due to NaN being
2572+
/// incomparable. You can work around this by using [`Iterator::reduce`]:
2573+
/// ```
2574+
/// assert_eq!(
2575+
/// vec![2.4, f32::NAN, 1.3]
2576+
/// .into_iter()
2577+
/// .reduce(f32::max)
2578+
/// .unwrap(),
2579+
/// 2.4
2580+
/// );
2581+
/// ```
2582+
///
25712583
/// # Examples
25722584
///
25732585
/// Basic usage:
@@ -2591,8 +2603,20 @@ pub trait Iterator {
25912603

25922604
/// Returns the minimum element of an iterator.
25932605
///
2594-
/// If several elements are equally minimum, the first element is
2595-
/// returned. If the iterator is empty, [`None`] is returned.
2606+
/// If several elements are equally minimum, the first element is returned.
2607+
/// If the iterator is empty, [`None`] is returned.
2608+
///
2609+
/// Note that [`f32`]/[`f64`] doesn't implement [`Ord`] due to NaN being
2610+
/// incomparable. You can work around this by using [`Iterator::reduce`]:
2611+
/// ```
2612+
/// assert_eq!(
2613+
/// vec![2.4, f32::NAN, 1.3]
2614+
/// .into_iter()
2615+
/// .reduce(f32::min)
2616+
/// .unwrap(),
2617+
/// 1.3
2618+
/// );
2619+
/// ```
25962620
///
25972621
/// # Examples
25982622
///

library/std/src/sys/unix/net.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ impl Socket {
6262
target_os = "illumos",
6363
target_os = "linux",
6464
target_os = "netbsd",
65-
target_os = "opensbd",
65+
target_os = "openbsd",
6666
))] {
6767
// On platforms that support it we pass the SOCK_CLOEXEC
6868
// flag to atomically create the socket and set it as
@@ -99,7 +99,7 @@ impl Socket {
9999
target_os = "illumos",
100100
target_os = "linux",
101101
target_os = "netbsd",
102-
target_os = "opensbd",
102+
target_os = "openbsd",
103103
))] {
104104
// Like above, set cloexec atomically
105105
cvt(libc::socketpair(fam, ty | libc::SOCK_CLOEXEC, 0, fds.as_mut_ptr()))?;
@@ -204,7 +204,7 @@ impl Socket {
204204
target_os = "illumos",
205205
target_os = "linux",
206206
target_os = "netbsd",
207-
target_os = "opensbd",
207+
target_os = "openbsd",
208208
))] {
209209
let fd = cvt_r(|| unsafe {
210210
libc::accept4(self.0.raw(), storage, len, libc::SOCK_CLOEXEC)

src/librustdoc/html/render/print_item.rs

+13-4
Original file line numberDiff line numberDiff line change
@@ -578,14 +578,23 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra
578578
info!("Documenting {} on {:?}", name, t.name);
579579
let item_type = m.type_();
580580
let id = cx.derive_id(format!("{}.{}", item_type, name));
581-
write!(w, "<details class=\"rustdoc-toggle\" open><summary>");
582-
write!(w, "<h3 id=\"{id}\" class=\"method\"><code>", id = id,);
581+
let mut content = Buffer::empty_from(w);
582+
document(&mut content, cx, m, Some(t));
583+
let toggled = !content.is_empty();
584+
if toggled {
585+
write!(w, "<details class=\"rustdoc-toggle\" open><summary>");
586+
}
587+
write!(w, "<h3 id=\"{id}\" class=\"method\"><code>", id = id);
583588
render_assoc_item(w, m, AssocItemLink::Anchor(Some(&id)), ItemType::Impl, cx);
584589
w.write_str("</code>");
585590
render_stability_since(w, m, t, cx.tcx());
586591
write_srclink(cx, m, w);
587-
w.write_str("</h3></summary>");
588-
document(w, cx, m, Some(t));
592+
w.write_str("</h3>");
593+
if toggled {
594+
write!(w, "</summary>");
595+
w.push_buffer(content);
596+
write!(w, "</details>");
597+
}
589598
}
590599

591600
if !types.is_empty() {

src/test/rustdoc/toggle-trait-fn.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
#![crate_name = "foo"]
22

33
// @has foo/trait.Foo.html
4-
// @has - '//details[@class="rustdoc-toggle"]//code' 'bar'
4+
// @!has - '//details[@class="rustdoc-toggle"]//code' 'bar'
5+
// @has - '//code' 'bar'
6+
// @has - '//details[@class="rustdoc-toggle"]//code' 'foo'
57
pub trait Foo {
68
fn bar() -> ();
9+
/// hello
10+
fn foo();
711
}

0 commit comments

Comments
 (0)