Skip to content

Commit c34faad

Browse files
committed
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.
1 parent bf193d6 commit c34faad

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/librustdoc/html/format.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,16 +1322,16 @@ impl clean::GenericArg {
13221322
}
13231323

13241324
crate fn display_fn(f: impl FnOnce(&mut fmt::Formatter<'_>) -> fmt::Result) -> impl fmt::Display {
1325-
WithFormatter(Cell::new(Some(f)))
1326-
}
1327-
1328-
struct WithFormatter<F>(Cell<Option<F>>);
1329-
1330-
impl<F> fmt::Display for WithFormatter<F>
1331-
where
1332-
F: FnOnce(&mut fmt::Formatter<'_>) -> fmt::Result,
1333-
{
1334-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1335-
(self.0.take()).unwrap()(f)
1325+
struct WithFormatter<F>(Cell<Option<F>>);
1326+
1327+
impl<F> fmt::Display for WithFormatter<F>
1328+
where
1329+
F: FnOnce(&mut fmt::Formatter<'_>) -> fmt::Result,
1330+
{
1331+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1332+
(self.0.take()).unwrap()(f)
1333+
}
13361334
}
1335+
1336+
WithFormatter(Cell::new(Some(f)))
13371337
}

0 commit comments

Comments
 (0)