Skip to content

Commit e044c57

Browse files
authored
Rollup merge of rust-lang#81497 - camelid:rustdoc-display_fn-remove-cell, r=jyn514
rustdoc: Move `display_fn` struct inside `display_fn` This makes it clear that it's an implementation detail of `display_fn` and shouldn't be used elsewhere, and it enforces in the compiler that no one else can use it. r? `@GuillaumeGomez`
2 parents 93d5b5f + c34faad commit e044c57

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/librustdoc/html/format.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -1331,16 +1331,16 @@ impl clean::GenericArg {
13311331
}
13321332

13331333
crate fn display_fn(f: impl FnOnce(&mut fmt::Formatter<'_>) -> fmt::Result) -> impl fmt::Display {
1334-
WithFormatter(Cell::new(Some(f)))
1335-
}
1336-
1337-
struct WithFormatter<F>(Cell<Option<F>>);
1338-
1339-
impl<F> fmt::Display for WithFormatter<F>
1340-
where
1341-
F: FnOnce(&mut fmt::Formatter<'_>) -> fmt::Result,
1342-
{
1343-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1344-
(self.0.take()).unwrap()(f)
1334+
struct WithFormatter<F>(Cell<Option<F>>);
1335+
1336+
impl<F> fmt::Display for WithFormatter<F>
1337+
where
1338+
F: FnOnce(&mut fmt::Formatter<'_>) -> fmt::Result,
1339+
{
1340+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1341+
(self.0.take()).unwrap()(f)
1342+
}
13451343
}
1344+
1345+
WithFormatter(Cell::new(Some(f)))
13461346
}

0 commit comments

Comments
 (0)