diff options
| author | Mara Bos <m-ou.se@m-ou.se> | 2021-02-05 12:25:58 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-02-05 12:25:58 +0100 |
| commit | 2451bf90db0b17c5f3cb8010d76730048a405c56 (patch) | |
| tree | ce062cfcad6aded83d7f0e6e108a5530628c6c8b | |
| parent | b5438e2230410edc8c5c67d9b114f6886af625dd (diff) | |
| parent | c34faadfdaf3938f24e9f7a4c3441ac581078ce4 (diff) | |
| download | rust-2451bf90db0b17c5f3cb8010d76730048a405c56.tar.gz rust-2451bf90db0b17c5f3cb8010d76730048a405c56.zip | |
Rollup merge of #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````
| -rw-r--r-- | src/librustdoc/html/format.rs | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index 74b61f1555c..d7951961223 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -1331,16 +1331,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<F>(Cell<Option<F>>); - -impl<F> fmt::Display for WithFormatter<F> -where - F: FnOnce(&mut fmt::Formatter<'_>) -> fmt::Result, -{ - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - (self.0.take()).unwrap()(f) + struct WithFormatter<F>(Cell<Option<F>>); + + impl<F> fmt::Display for WithFormatter<F> + 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))) } |
