From c34faadfdaf3938f24e9f7a4c3441ac581078ce4 Mon Sep 17 00:00:00 2001 From: Camelid Date: Thu, 28 Jan 2021 19:04:29 -0800 Subject: [PATCH] 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. --- src/librustdoc/html/format.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index 01915c33a07ad..8fd1c1d1cc652 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -1322,16 +1322,16 @@ impl clean::GenericArg { } crate fn display_fn(f: impl FnOnce(&mut fmt::Formatter<'_>) -> fmt::Result) -> impl fmt::Display { - WithFormatter(Cell::new(Some(f))) -} - -struct WithFormatter(Cell>); - -impl fmt::Display for WithFormatter -where - F: FnOnce(&mut fmt::Formatter<'_>) -> fmt::Result, -{ - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - (self.0.take()).unwrap()(f) + struct WithFormatter(Cell>); + + impl fmt::Display for WithFormatter + where + F: FnOnce(&mut fmt::Formatter<'_>) -> fmt::Result, + { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + (self.0.take()).unwrap()(f) + } } + + WithFormatter(Cell::new(Some(f))) }