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