Running into borrow issue on intermediate.
This commit is contained in:
parent
f98a09bc59
commit
3d44d20384
@ -1,3 +1,4 @@
|
|||||||
|
use super::macros::iitem;
|
||||||
use super::macros::iselector;
|
use super::macros::iselector;
|
||||||
use super::registry::Registry;
|
use super::registry::Registry;
|
||||||
use super::IHeading;
|
use super::IHeading;
|
||||||
@ -15,13 +16,19 @@ iselector!(
|
|||||||
IDocumentElement,
|
IDocumentElement,
|
||||||
DocumentElement,
|
DocumentElement,
|
||||||
|registry, original| async {
|
|registry, original| async {
|
||||||
match &original {
|
iitem!(
|
||||||
organic::types::DocumentElement::Heading(inner) => Ok(IDocumentElement::Heading(
|
registry,
|
||||||
IHeading::new(registry, inner).await?,
|
original,
|
||||||
)),
|
(
|
||||||
organic::types::DocumentElement::Section(inner) => Ok(IDocumentElement::Section(
|
organic::types::DocumentElement::Heading,
|
||||||
ISection::new(registry, inner).await?,
|
IDocumentElement::Heading,
|
||||||
)),
|
IHeading
|
||||||
}
|
),
|
||||||
|
(
|
||||||
|
organic::types::DocumentElement::Section,
|
||||||
|
IDocumentElement::Section,
|
||||||
|
ISection
|
||||||
|
),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -15,7 +15,6 @@ use super::IFixedWidthArea;
|
|||||||
use super::IFootnoteDefinition;
|
use super::IFootnoteDefinition;
|
||||||
use super::IHorizontalRule;
|
use super::IHorizontalRule;
|
||||||
use super::ILatexEnvironment;
|
use super::ILatexEnvironment;
|
||||||
use super::IObject;
|
|
||||||
use super::IParagraph;
|
use super::IParagraph;
|
||||||
use super::IPlainList;
|
use super::IPlainList;
|
||||||
use super::IPlanning;
|
use super::IPlanning;
|
||||||
@ -26,6 +25,7 @@ use super::ISrcBlock;
|
|||||||
use super::ITable;
|
use super::ITable;
|
||||||
use super::IVerseBlock;
|
use super::IVerseBlock;
|
||||||
use crate::error::CustomError;
|
use crate::error::CustomError;
|
||||||
|
use crate::intermediate::macros::iitem;
|
||||||
use futures::future::{BoxFuture, FutureExt};
|
use futures::future::{BoxFuture, FutureExt};
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
@ -56,79 +56,117 @@ pub(crate) enum IElement {
|
|||||||
LatexEnvironment(ILatexEnvironment),
|
LatexEnvironment(ILatexEnvironment),
|
||||||
}
|
}
|
||||||
|
|
||||||
iselector!(IElement, Element, |registry, elem| async {
|
iselector!(IElement, Element, |registry, original| async {
|
||||||
match elem {
|
iitem!(
|
||||||
organic::types::Element::Paragraph(inner) => {
|
registry,
|
||||||
Ok(IElement::Paragraph(IParagraph::new(registry, inner).await?))
|
original,
|
||||||
}
|
(
|
||||||
organic::types::Element::PlainList(inner) => {
|
organic::types::Element::Paragraph,
|
||||||
Ok(IElement::PlainList(IPlainList::new(registry, inner).await?))
|
IElement::Paragraph,
|
||||||
}
|
IParagraph
|
||||||
organic::types::Element::CenterBlock(inner) => Ok(IElement::CenterBlock(
|
),
|
||||||
ICenterBlock::new(registry, inner).await?,
|
(
|
||||||
)),
|
organic::types::Element::PlainList,
|
||||||
organic::types::Element::QuoteBlock(inner) => Ok(IElement::QuoteBlock(
|
IElement::PlainList,
|
||||||
IQuoteBlock::new(registry, inner).await?,
|
IPlainList
|
||||||
)),
|
),
|
||||||
organic::types::Element::SpecialBlock(inner) => Ok(IElement::SpecialBlock(
|
(
|
||||||
ISpecialBlock::new(registry, inner).await?,
|
organic::types::Element::CenterBlock,
|
||||||
)),
|
IElement::CenterBlock,
|
||||||
organic::types::Element::DynamicBlock(inner) => Ok(IElement::DynamicBlock(
|
ICenterBlock
|
||||||
IDynamicBlock::new(registry, inner).await?,
|
),
|
||||||
)),
|
(
|
||||||
organic::types::Element::FootnoteDefinition(inner) => Ok(IElement::FootnoteDefinition(
|
organic::types::Element::QuoteBlock,
|
||||||
IFootnoteDefinition::new(registry, inner).await?,
|
IElement::QuoteBlock,
|
||||||
)),
|
IQuoteBlock
|
||||||
organic::types::Element::Comment(inner) => {
|
),
|
||||||
Ok(IElement::Comment(IComment::new(registry, inner).await?))
|
(
|
||||||
}
|
organic::types::Element::SpecialBlock,
|
||||||
organic::types::Element::Drawer(inner) => {
|
IElement::SpecialBlock,
|
||||||
Ok(IElement::Drawer(IDrawer::new(registry, inner).await?))
|
ISpecialBlock
|
||||||
}
|
),
|
||||||
organic::types::Element::PropertyDrawer(inner) => Ok(IElement::PropertyDrawer(
|
(
|
||||||
IPropertyDrawer::new(registry, inner).await?,
|
organic::types::Element::DynamicBlock,
|
||||||
)),
|
IElement::DynamicBlock,
|
||||||
organic::types::Element::Table(inner) => {
|
IDynamicBlock
|
||||||
Ok(IElement::Table(ITable::new(registry, inner).await?))
|
),
|
||||||
}
|
(
|
||||||
organic::types::Element::VerseBlock(inner) => Ok(IElement::VerseBlock(
|
organic::types::Element::FootnoteDefinition,
|
||||||
IVerseBlock::new(registry, inner).await?,
|
IElement::FootnoteDefinition,
|
||||||
)),
|
IFootnoteDefinition
|
||||||
organic::types::Element::CommentBlock(inner) => Ok(IElement::CommentBlock(
|
),
|
||||||
ICommentBlock::new(registry, inner).await?,
|
(
|
||||||
)),
|
organic::types::Element::Comment,
|
||||||
organic::types::Element::ExampleBlock(inner) => Ok(IElement::ExampleBlock(
|
IElement::Comment,
|
||||||
IExampleBlock::new(registry, inner).await?,
|
IComment
|
||||||
)),
|
),
|
||||||
organic::types::Element::ExportBlock(inner) => Ok(IElement::ExportBlock(
|
(organic::types::Element::Drawer, IElement::Drawer, IDrawer),
|
||||||
IExportBlock::new(registry, inner).await?,
|
(
|
||||||
)),
|
organic::types::Element::PropertyDrawer,
|
||||||
organic::types::Element::SrcBlock(inner) => {
|
IElement::PropertyDrawer,
|
||||||
Ok(IElement::SrcBlock(ISrcBlock::new(registry, inner).await?))
|
IPropertyDrawer
|
||||||
}
|
),
|
||||||
organic::types::Element::Clock(inner) => {
|
(organic::types::Element::Table, IElement::Table, ITable),
|
||||||
Ok(IElement::Clock(IClock::new(registry, inner).await?))
|
(
|
||||||
}
|
organic::types::Element::VerseBlock,
|
||||||
organic::types::Element::DiarySexp(inner) => {
|
IElement::VerseBlock,
|
||||||
Ok(IElement::DiarySexp(IDiarySexp::new(registry, inner).await?))
|
IVerseBlock
|
||||||
}
|
),
|
||||||
organic::types::Element::Planning(inner) => {
|
(
|
||||||
Ok(IElement::Planning(IPlanning::new(registry, inner).await?))
|
organic::types::Element::CommentBlock,
|
||||||
}
|
IElement::CommentBlock,
|
||||||
organic::types::Element::FixedWidthArea(inner) => Ok(IElement::FixedWidthArea(
|
ICommentBlock
|
||||||
IFixedWidthArea::new(registry, inner).await?,
|
),
|
||||||
)),
|
(
|
||||||
organic::types::Element::HorizontalRule(inner) => Ok(IElement::HorizontalRule(
|
organic::types::Element::ExampleBlock,
|
||||||
IHorizontalRule::new(registry, inner).await?,
|
IElement::ExampleBlock,
|
||||||
)),
|
IExampleBlock
|
||||||
organic::types::Element::Keyword(inner) => {
|
),
|
||||||
Ok(IElement::Keyword(IKeyword::new(registry, inner).await?))
|
(
|
||||||
}
|
organic::types::Element::ExportBlock,
|
||||||
organic::types::Element::BabelCall(inner) => {
|
IElement::ExportBlock,
|
||||||
Ok(IElement::BabelCall(IBabelCall::new(registry, inner).await?))
|
IExportBlock
|
||||||
}
|
),
|
||||||
organic::types::Element::LatexEnvironment(inner) => Ok(IElement::LatexEnvironment(
|
(
|
||||||
ILatexEnvironment::new(registry, inner).await?,
|
organic::types::Element::SrcBlock,
|
||||||
)),
|
IElement::SrcBlock,
|
||||||
}
|
ISrcBlock
|
||||||
|
),
|
||||||
|
(organic::types::Element::Clock, IElement::Clock, IClock),
|
||||||
|
(
|
||||||
|
organic::types::Element::DiarySexp,
|
||||||
|
IElement::DiarySexp,
|
||||||
|
IDiarySexp
|
||||||
|
),
|
||||||
|
(
|
||||||
|
organic::types::Element::Planning,
|
||||||
|
IElement::Planning,
|
||||||
|
IPlanning
|
||||||
|
),
|
||||||
|
(
|
||||||
|
organic::types::Element::FixedWidthArea,
|
||||||
|
IElement::FixedWidthArea,
|
||||||
|
IFixedWidthArea
|
||||||
|
),
|
||||||
|
(
|
||||||
|
organic::types::Element::HorizontalRule,
|
||||||
|
IElement::HorizontalRule,
|
||||||
|
IHorizontalRule
|
||||||
|
),
|
||||||
|
(
|
||||||
|
organic::types::Element::Keyword,
|
||||||
|
IElement::Keyword,
|
||||||
|
IKeyword
|
||||||
|
),
|
||||||
|
(
|
||||||
|
organic::types::Element::BabelCall,
|
||||||
|
IElement::BabelCall,
|
||||||
|
IBabelCall
|
||||||
|
),
|
||||||
|
(
|
||||||
|
organic::types::Element::LatexEnvironment,
|
||||||
|
IElement::LatexEnvironment,
|
||||||
|
ILatexEnvironment
|
||||||
|
),
|
||||||
|
)
|
||||||
});
|
});
|
||||||
|
@ -54,3 +54,17 @@ macro_rules! iselector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) use iselector;
|
pub(crate) use iselector;
|
||||||
|
|
||||||
|
macro_rules! iitem {
|
||||||
|
($registry:expr, $original:expr, $(($penum:path, $ienum:path, $istruct:ident),)*) => {
|
||||||
|
match $original {
|
||||||
|
$(
|
||||||
|
&$penum(inner) => Ok($ienum(
|
||||||
|
$istruct::new($registry, &inner).await?,
|
||||||
|
)),
|
||||||
|
)*
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) use iitem;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
use crate::error::CustomError;
|
use crate::error::CustomError;
|
||||||
|
use crate::intermediate::macros::iitem;
|
||||||
|
|
||||||
use super::angle_link::IAngleLink;
|
use super::angle_link::IAngleLink;
|
||||||
use super::bold::IBold;
|
use super::bold::IBold;
|
||||||
@ -62,88 +63,124 @@ pub(crate) enum IObject {
|
|||||||
Timestamp(ITimestamp),
|
Timestamp(ITimestamp),
|
||||||
}
|
}
|
||||||
|
|
||||||
iselector!(IObject, Object, |registry, obj| async {
|
iselector!(IObject, Object, |registry, original| async {
|
||||||
match &obj {
|
iitem!(
|
||||||
organic::types::Object::Bold(inner) => {
|
registry,
|
||||||
Ok(IObject::Bold(IBold::new(registry, inner).await?))
|
original,
|
||||||
}
|
(organic::types::Object::Bold, IObject::Bold, IBold),
|
||||||
organic::types::Object::Italic(inner) => {
|
(organic::types::Object::Italic, IObject::Italic, IItalic),
|
||||||
Ok(IObject::Italic(IItalic::new(registry, inner).await?))
|
(
|
||||||
}
|
organic::types::Object::Underline,
|
||||||
organic::types::Object::Underline(inner) => {
|
IObject::Underline,
|
||||||
Ok(IObject::Underline(IUnderline::new(registry, inner).await?))
|
IUnderline
|
||||||
}
|
),
|
||||||
organic::types::Object::StrikeThrough(inner) => Ok(IObject::StrikeThrough(
|
(
|
||||||
IStrikeThrough::new(registry, inner).await?,
|
organic::types::Object::StrikeThrough,
|
||||||
)),
|
IObject::StrikeThrough,
|
||||||
organic::types::Object::Code(inner) => {
|
IStrikeThrough
|
||||||
Ok(IObject::Code(ICode::new(registry, inner).await?))
|
),
|
||||||
}
|
(organic::types::Object::Code, IObject::Code, ICode),
|
||||||
organic::types::Object::Verbatim(inner) => {
|
(
|
||||||
Ok(IObject::Verbatim(IVerbatim::new(registry, inner).await?))
|
organic::types::Object::Verbatim,
|
||||||
}
|
IObject::Verbatim,
|
||||||
organic::types::Object::PlainText(inner) => {
|
IVerbatim
|
||||||
Ok(IObject::PlainText(IPlainText::new(registry, inner).await?))
|
),
|
||||||
}
|
(
|
||||||
organic::types::Object::RegularLink(inner) => Ok(IObject::RegularLink(
|
organic::types::Object::PlainText,
|
||||||
IRegularLink::new(registry, inner).await?,
|
IObject::PlainText,
|
||||||
)),
|
IPlainText
|
||||||
organic::types::Object::RadioLink(inner) => {
|
),
|
||||||
Ok(IObject::RadioLink(IRadioLink::new(registry, inner).await?))
|
(
|
||||||
}
|
organic::types::Object::RegularLink,
|
||||||
organic::types::Object::RadioTarget(inner) => Ok(IObject::RadioTarget(
|
IObject::RegularLink,
|
||||||
IRadioTarget::new(registry, inner).await?,
|
IRegularLink
|
||||||
)),
|
),
|
||||||
organic::types::Object::PlainLink(inner) => {
|
(
|
||||||
Ok(IObject::PlainLink(IPlainLink::new(registry, inner).await?))
|
organic::types::Object::RadioLink,
|
||||||
}
|
IObject::RadioLink,
|
||||||
organic::types::Object::AngleLink(inner) => {
|
IRadioLink
|
||||||
Ok(IObject::AngleLink(IAngleLink::new(registry, inner).await?))
|
),
|
||||||
}
|
(
|
||||||
organic::types::Object::OrgMacro(inner) => {
|
organic::types::Object::RadioTarget,
|
||||||
Ok(IObject::OrgMacro(IOrgMacro::new(registry, inner).await?))
|
IObject::RadioTarget,
|
||||||
}
|
IRadioTarget
|
||||||
organic::types::Object::Entity(inner) => {
|
),
|
||||||
Ok(IObject::Entity(IEntity::new(registry, inner).await?))
|
(
|
||||||
}
|
organic::types::Object::PlainLink,
|
||||||
organic::types::Object::LatexFragment(inner) => Ok(IObject::LatexFragment(
|
IObject::PlainLink,
|
||||||
ILatexFragment::new(registry, inner).await?,
|
IPlainLink
|
||||||
)),
|
),
|
||||||
organic::types::Object::ExportSnippet(inner) => Ok(IObject::ExportSnippet(
|
(
|
||||||
IExportSnippet::new(registry, inner).await?,
|
organic::types::Object::AngleLink,
|
||||||
)),
|
IObject::AngleLink,
|
||||||
organic::types::Object::FootnoteReference(inner) => Ok(IObject::FootnoteReference(
|
IAngleLink
|
||||||
IFootnoteReference::new(registry, inner).await?,
|
),
|
||||||
)),
|
(
|
||||||
organic::types::Object::Citation(inner) => {
|
organic::types::Object::OrgMacro,
|
||||||
Ok(IObject::Citation(ICitation::new(registry, inner).await?))
|
IObject::OrgMacro,
|
||||||
}
|
IOrgMacro
|
||||||
organic::types::Object::CitationReference(inner) => Ok(IObject::CitationReference(
|
),
|
||||||
ICitationReference::new(registry, inner).await?,
|
(organic::types::Object::Entity, IObject::Entity, IEntity),
|
||||||
)),
|
(
|
||||||
organic::types::Object::InlineBabelCall(inner) => Ok(IObject::InlineBabelCall(
|
organic::types::Object::LatexFragment,
|
||||||
IInlineBabelCall::new(registry, inner).await?,
|
IObject::LatexFragment,
|
||||||
)),
|
ILatexFragment
|
||||||
organic::types::Object::InlineSourceBlock(inner) => Ok(IObject::InlineSourceBlock(
|
),
|
||||||
IInlineSourceBlock::new(registry, inner).await?,
|
(
|
||||||
)),
|
organic::types::Object::ExportSnippet,
|
||||||
organic::types::Object::LineBreak(inner) => {
|
IObject::ExportSnippet,
|
||||||
Ok(IObject::LineBreak(ILineBreak::new(registry, inner).await?))
|
IExportSnippet
|
||||||
}
|
),
|
||||||
organic::types::Object::Target(inner) => {
|
(
|
||||||
Ok(IObject::Target(ITarget::new(registry, inner).await?))
|
organic::types::Object::FootnoteReference,
|
||||||
}
|
IObject::FootnoteReference,
|
||||||
organic::types::Object::StatisticsCookie(inner) => Ok(IObject::StatisticsCookie(
|
IFootnoteReference
|
||||||
IStatisticsCookie::new(registry, inner).await?,
|
),
|
||||||
)),
|
(
|
||||||
organic::types::Object::Subscript(inner) => {
|
organic::types::Object::Citation,
|
||||||
Ok(IObject::Subscript(ISubscript::new(registry, inner).await?))
|
IObject::Citation,
|
||||||
}
|
ICitation
|
||||||
organic::types::Object::Superscript(inner) => Ok(IObject::Superscript(
|
),
|
||||||
ISuperscript::new(registry, inner).await?,
|
(
|
||||||
)),
|
organic::types::Object::CitationReference,
|
||||||
organic::types::Object::Timestamp(inner) => {
|
IObject::CitationReference,
|
||||||
Ok(IObject::Timestamp(ITimestamp::new(registry, inner).await?))
|
ICitationReference
|
||||||
}
|
),
|
||||||
}
|
(
|
||||||
|
organic::types::Object::InlineBabelCall,
|
||||||
|
IObject::InlineBabelCall,
|
||||||
|
IInlineBabelCall
|
||||||
|
),
|
||||||
|
(
|
||||||
|
organic::types::Object::InlineSourceBlock,
|
||||||
|
IObject::InlineSourceBlock,
|
||||||
|
IInlineSourceBlock
|
||||||
|
),
|
||||||
|
(
|
||||||
|
organic::types::Object::LineBreak,
|
||||||
|
IObject::LineBreak,
|
||||||
|
ILineBreak
|
||||||
|
),
|
||||||
|
(organic::types::Object::Target, IObject::Target, ITarget),
|
||||||
|
(
|
||||||
|
organic::types::Object::StatisticsCookie,
|
||||||
|
IObject::StatisticsCookie,
|
||||||
|
IStatisticsCookie
|
||||||
|
),
|
||||||
|
(
|
||||||
|
organic::types::Object::Subscript,
|
||||||
|
IObject::Subscript,
|
||||||
|
ISubscript
|
||||||
|
),
|
||||||
|
(
|
||||||
|
organic::types::Object::Superscript,
|
||||||
|
IObject::Superscript,
|
||||||
|
ISuperscript
|
||||||
|
),
|
||||||
|
(
|
||||||
|
organic::types::Object::Timestamp,
|
||||||
|
IObject::Timestamp,
|
||||||
|
ITimestamp
|
||||||
|
),
|
||||||
|
)
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user