librustdoc: use unboxed closures
This commit is contained in:
parent
0676c3bf03
commit
888f24969f
2 changed files with 17 additions and 8 deletions
|
@ -218,10 +218,14 @@ fn resolved_path(w: &mut fmt::Formatter, did: ast::DefId, p: &clean::Path,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn path(w: &mut fmt::Formatter, path: &clean::Path, print_all: bool,
|
fn path<F, G>(w: &mut fmt::Formatter,
|
||||||
root: |&render::Cache, &[String]| -> Option<String>,
|
path: &clean::Path,
|
||||||
info: |&render::Cache| -> Option<(Vec<String> , ItemType)>)
|
print_all: bool,
|
||||||
-> fmt::Result
|
root: F,
|
||||||
|
info: G)
|
||||||
|
-> fmt::Result where
|
||||||
|
F: FnOnce(&render::Cache, &[String]) -> Option<String>,
|
||||||
|
G: FnOnce(&render::Cache) -> Option<(Vec<String>, ItemType)>,
|
||||||
{
|
{
|
||||||
// The generics will get written to both the title and link
|
// The generics will get written to both the title and link
|
||||||
let mut generics = String::new();
|
let mut generics = String::new();
|
||||||
|
|
|
@ -646,7 +646,9 @@ fn shortty(item: &clean::Item) -> ItemType {
|
||||||
/// static HTML tree.
|
/// static HTML tree.
|
||||||
// FIXME (#9639): The closure should deal with &[u8] instead of &str
|
// FIXME (#9639): The closure should deal with &[u8] instead of &str
|
||||||
// FIXME (#9639): This is too conservative, rejecting non-UTF-8 paths
|
// FIXME (#9639): This is too conservative, rejecting non-UTF-8 paths
|
||||||
fn clean_srcpath(src_root: &Path, src: &[u8], f: |&str|) {
|
fn clean_srcpath<F>(src_root: &Path, src: &[u8], mut f: F) where
|
||||||
|
F: FnMut(&str),
|
||||||
|
{
|
||||||
let p = Path::new(src);
|
let p = Path::new(src);
|
||||||
|
|
||||||
// make it relative, if possible
|
// make it relative, if possible
|
||||||
|
@ -1051,7 +1053,9 @@ impl<'a> Cache {
|
||||||
impl Context {
|
impl Context {
|
||||||
/// Recurse in the directory structure and change the "root path" to make
|
/// Recurse in the directory structure and change the "root path" to make
|
||||||
/// sure it always points to the top (relatively)
|
/// sure it always points to the top (relatively)
|
||||||
fn recurse<T>(&mut self, s: String, f: |&mut Context| -> T) -> T {
|
fn recurse<T, F>(&mut self, s: String, f: F) -> T where
|
||||||
|
F: FnOnce(&mut Context) -> T,
|
||||||
|
{
|
||||||
if s.len() == 0 {
|
if s.len() == 0 {
|
||||||
panic!("Unexpected empty destination: {}", self.current);
|
panic!("Unexpected empty destination: {}", self.current);
|
||||||
}
|
}
|
||||||
|
@ -1131,8 +1135,9 @@ impl Context {
|
||||||
/// all sub-items which need to be rendered.
|
/// all sub-items which need to be rendered.
|
||||||
///
|
///
|
||||||
/// The rendering driver uses this closure to queue up more work.
|
/// The rendering driver uses this closure to queue up more work.
|
||||||
fn item(&mut self, item: clean::Item,
|
fn item<F>(&mut self, item: clean::Item, mut f: F) -> io::IoResult<()> where
|
||||||
f: |&mut Context, clean::Item|) -> io::IoResult<()> {
|
F: FnMut(&mut Context, clean::Item),
|
||||||
|
{
|
||||||
fn render(w: io::File, cx: &Context, it: &clean::Item,
|
fn render(w: io::File, cx: &Context, it: &clean::Item,
|
||||||
pushname: bool) -> io::IoResult<()> {
|
pushname: bool) -> io::IoResult<()> {
|
||||||
info!("Rendering an item to {}", w.path().display());
|
info!("Rendering an item to {}", w.path().display());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue