Remove closures from iselector macro.
This commit is contained in:
parent
24b9782146
commit
a966be8122
@ -12,23 +12,19 @@ pub(crate) enum IDocumentElement {
|
||||
Section(ISection),
|
||||
}
|
||||
|
||||
iselector!(
|
||||
IDocumentElement,
|
||||
DocumentElement,
|
||||
|registry, original| async {
|
||||
iitem!(
|
||||
registry,
|
||||
original,
|
||||
(
|
||||
organic::types::DocumentElement::Heading,
|
||||
IDocumentElement::Heading,
|
||||
IHeading
|
||||
),
|
||||
(
|
||||
organic::types::DocumentElement::Section,
|
||||
IDocumentElement::Section,
|
||||
ISection
|
||||
),
|
||||
)
|
||||
}
|
||||
);
|
||||
iselector!(IDocumentElement, DocumentElement, original, registry, {
|
||||
iitem!(
|
||||
registry,
|
||||
original,
|
||||
(
|
||||
organic::types::DocumentElement::Heading,
|
||||
IDocumentElement::Heading,
|
||||
IHeading
|
||||
),
|
||||
(
|
||||
organic::types::DocumentElement::Section,
|
||||
IDocumentElement::Section,
|
||||
ISection
|
||||
),
|
||||
)
|
||||
});
|
||||
|
@ -56,7 +56,7 @@ pub(crate) enum IElement {
|
||||
LatexEnvironment(ILatexEnvironment),
|
||||
}
|
||||
|
||||
iselector!(IElement, Element, |registry, original| async {
|
||||
iselector!(IElement, Element, original, registry, {
|
||||
iitem!(
|
||||
registry,
|
||||
original,
|
||||
|
@ -43,13 +43,18 @@ pub(crate) use intermediate;
|
||||
///
|
||||
/// This exists to make changing the type signature easier.
|
||||
macro_rules! iselector {
|
||||
($istruct:ident, $pstruct:ident, $fnbody:expr) => {
|
||||
($istruct:ident, $pstruct:ident, $original:ident, $registry:ident, $fnbody:tt) => {
|
||||
impl $istruct {
|
||||
pub(crate) fn new<'reg, 'orig, 'parse, 'inp: 'reg + 'orig>(
|
||||
pub(crate) fn new<'reg, 'orig, 'parse, 'inp: 'reg + 'orig + 'parse>(
|
||||
registry: &'reg mut Registry<'orig, 'parse>,
|
||||
original: &'orig organic::types::$pstruct<'parse>,
|
||||
) -> BoxFuture<'inp, Result<$istruct, CustomError>> {
|
||||
$fnbody(registry, original).boxed()
|
||||
async move {
|
||||
let $registry = registry;
|
||||
let $original = original;
|
||||
$fnbody
|
||||
}
|
||||
.boxed()
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -61,8 +66,8 @@ macro_rules! iitem {
|
||||
($registry:expr, $original:expr, $(($penum:path, $ienum:path, $istruct:ident),)*) => {
|
||||
match $original {
|
||||
$(
|
||||
&$penum(inner) => Ok($ienum(
|
||||
$istruct::new($registry, &inner).await?,
|
||||
$penum(inner) => Ok($ienum(
|
||||
$istruct::new($registry, inner).await?,
|
||||
)),
|
||||
)*
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ pub(crate) enum IObject {
|
||||
Timestamp(ITimestamp),
|
||||
}
|
||||
|
||||
iselector!(IObject, Object, |registry, original| async {
|
||||
iselector!(IObject, Object, original, registry, {
|
||||
iitem!(
|
||||
registry,
|
||||
original,
|
||||
|
Loading…
x
Reference in New Issue
Block a user