Avoid closures for the intermediate macro.

This commit is contained in:
Tom Alexander
2023-10-29 18:35:42 -04:00
parent 3d44d20384
commit 24b9782146
16 changed files with 40 additions and 51 deletions

View File

@@ -1,4 +1,5 @@
use std::collections::HashMap;
use std::marker::PhantomData;
use super::ast_node::IntoIAstNode;
use crate::error::CustomError;
@@ -12,10 +13,8 @@ type IdCounter = u16;
pub(crate) struct Registry<'orig, 'parse> {
id_counter: IdCounter,
targets: HashMap<&'parse str, String>,
footnote_ids: Vec<(
Option<&'parse str>,
FootnoteDefinitionContents<'orig, 'parse>,
)>,
footnote_ids: Vec<(Option<&'parse str>, Vec<IAstNode>)>,
_phantom: PhantomData<&'orig ()>,
}
impl<'orig, 'parse> Registry<'orig, 'parse> {
@@ -24,6 +23,7 @@ impl<'orig, 'parse> Registry<'orig, 'parse> {
id_counter: 0,
targets: HashMap::new(),
footnote_ids: Vec::new(),
_phantom: PhantomData,
}
}
@@ -35,12 +35,10 @@ impl<'orig, 'parse> Registry<'orig, 'parse> {
}
pub(crate) fn get_footnote_ids(&self) -> impl Iterator<Item = (usize, &Vec<IAstNode>)> {
// TODO
std::iter::empty()
// self.footnote_ids
// .iter()
// .map(|(_label, definition)| definition)
// .enumerate()
self.footnote_ids
.iter()
.map(|(_label, definition)| definition)
.enumerate()
}
/// Get a 0-indexed ID for a footnote.
@@ -126,8 +124,3 @@ async fn convert_definition_contents<'reg, 'orig, 'parse>(
Ok(contents)
}
enum FootnoteDefinitionContents<'orig, 'parse> {
FromReference(&'orig Vec<Object<'parse>>),
FromDefinition(&'orig Vec<Object<'parse>>),
}