Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/librustdoc/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

use std::fmt::{self, Display, Formatter, FormattingOptions};

use crate::html::render::Context;

pub(crate) trait Joined: IntoIterator {
/// Takes an iterator over elements that implement [`Display`], and format them into `f`, separated by `sep`.
///
Expand Down Expand Up @@ -129,3 +131,16 @@ impl WithOpts {
})
}
}

pub(crate) trait DisplayFn<C: ?Sized> {
fn display_fn(&self, clean_item: &C, cx: &Context<'_>) -> impl Display;
}

impl<F, C: ?Sized> DisplayFn<C> for F
where
F: Fn(&mut Formatter<'_>, &C, &Context<'_>) -> fmt::Result,
{
fn display_fn(&self, clean_item: &C, cx: &Context<'_>) -> impl Display {
fmt::from_fn(move |f| self(f, clean_item, cx))
}
}
Loading
Loading