Skip to content

Commit c7f0154

Browse files
committed
Make render_long_plain return an impl fmt::Display
1 parent 060d2eb commit c7f0154

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/librustdoc/clean/cfg.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -189,14 +189,16 @@ impl Cfg {
189189
}
190190

191191
/// Renders the configuration for long display, as a long plain text description.
192-
pub(crate) fn render_long_plain(&self) -> String {
192+
pub(crate) fn render_long_plain(&self) -> impl fmt::Display + '_ {
193193
let on = if self.should_use_with_in_description() { "with" } else { "on" };
194194

195-
let mut msg = format!("Available {on} {}", Display(self, Format::LongPlain));
196-
if self.should_append_only_to_description() {
197-
msg.push_str(" only");
198-
}
199-
msg
195+
fmt::from_fn(move |f| {
196+
write!(f, "Available {on} {}", Display(self, Format::LongPlain))?;
197+
if self.should_append_only_to_description() {
198+
f.write_str(" only")?;
199+
}
200+
Ok(())
201+
})
200202
}
201203

202204
fn should_capitalize_first_letter(&self) -> bool {

0 commit comments

Comments
 (0)