Running into borrow issue on intermediate.

This commit is contained in:
Tom Alexander
2023-10-29 18:26:52 -04:00
parent f98a09bc59
commit 3d44d20384
4 changed files with 264 additions and 168 deletions

View File

@@ -15,7 +15,6 @@ use super::IFixedWidthArea;
use super::IFootnoteDefinition;
use super::IHorizontalRule;
use super::ILatexEnvironment;
use super::IObject;
use super::IParagraph;
use super::IPlainList;
use super::IPlanning;
@@ -26,6 +25,7 @@ use super::ISrcBlock;
use super::ITable;
use super::IVerseBlock;
use crate::error::CustomError;
use crate::intermediate::macros::iitem;
use futures::future::{BoxFuture, FutureExt};
#[derive(Debug, Clone)]
@@ -56,79 +56,117 @@ pub(crate) enum IElement {
LatexEnvironment(ILatexEnvironment),
}
iselector!(IElement, Element, |registry, elem| async {
match elem {
organic::types::Element::Paragraph(inner) => {
Ok(IElement::Paragraph(IParagraph::new(registry, inner).await?))
}
organic::types::Element::PlainList(inner) => {
Ok(IElement::PlainList(IPlainList::new(registry, inner).await?))
}
organic::types::Element::CenterBlock(inner) => Ok(IElement::CenterBlock(
ICenterBlock::new(registry, inner).await?,
)),
organic::types::Element::QuoteBlock(inner) => Ok(IElement::QuoteBlock(
IQuoteBlock::new(registry, inner).await?,
)),
organic::types::Element::SpecialBlock(inner) => Ok(IElement::SpecialBlock(
ISpecialBlock::new(registry, inner).await?,
)),
organic::types::Element::DynamicBlock(inner) => Ok(IElement::DynamicBlock(
IDynamicBlock::new(registry, inner).await?,
)),
organic::types::Element::FootnoteDefinition(inner) => Ok(IElement::FootnoteDefinition(
IFootnoteDefinition::new(registry, inner).await?,
)),
organic::types::Element::Comment(inner) => {
Ok(IElement::Comment(IComment::new(registry, inner).await?))
}
organic::types::Element::Drawer(inner) => {
Ok(IElement::Drawer(IDrawer::new(registry, inner).await?))
}
organic::types::Element::PropertyDrawer(inner) => Ok(IElement::PropertyDrawer(
IPropertyDrawer::new(registry, inner).await?,
)),
organic::types::Element::Table(inner) => {
Ok(IElement::Table(ITable::new(registry, inner).await?))
}
organic::types::Element::VerseBlock(inner) => Ok(IElement::VerseBlock(
IVerseBlock::new(registry, inner).await?,
)),
organic::types::Element::CommentBlock(inner) => Ok(IElement::CommentBlock(
ICommentBlock::new(registry, inner).await?,
)),
organic::types::Element::ExampleBlock(inner) => Ok(IElement::ExampleBlock(
IExampleBlock::new(registry, inner).await?,
)),
organic::types::Element::ExportBlock(inner) => Ok(IElement::ExportBlock(
IExportBlock::new(registry, inner).await?,
)),
organic::types::Element::SrcBlock(inner) => {
Ok(IElement::SrcBlock(ISrcBlock::new(registry, inner).await?))
}
organic::types::Element::Clock(inner) => {
Ok(IElement::Clock(IClock::new(registry, inner).await?))
}
organic::types::Element::DiarySexp(inner) => {
Ok(IElement::DiarySexp(IDiarySexp::new(registry, inner).await?))
}
organic::types::Element::Planning(inner) => {
Ok(IElement::Planning(IPlanning::new(registry, inner).await?))
}
organic::types::Element::FixedWidthArea(inner) => Ok(IElement::FixedWidthArea(
IFixedWidthArea::new(registry, inner).await?,
)),
organic::types::Element::HorizontalRule(inner) => Ok(IElement::HorizontalRule(
IHorizontalRule::new(registry, inner).await?,
)),
organic::types::Element::Keyword(inner) => {
Ok(IElement::Keyword(IKeyword::new(registry, inner).await?))
}
organic::types::Element::BabelCall(inner) => {
Ok(IElement::BabelCall(IBabelCall::new(registry, inner).await?))
}
organic::types::Element::LatexEnvironment(inner) => Ok(IElement::LatexEnvironment(
ILatexEnvironment::new(registry, inner).await?,
)),
}
iselector!(IElement, Element, |registry, original| async {
iitem!(
registry,
original,
(
organic::types::Element::Paragraph,
IElement::Paragraph,
IParagraph
),
(
organic::types::Element::PlainList,
IElement::PlainList,
IPlainList
),
(
organic::types::Element::CenterBlock,
IElement::CenterBlock,
ICenterBlock
),
(
organic::types::Element::QuoteBlock,
IElement::QuoteBlock,
IQuoteBlock
),
(
organic::types::Element::SpecialBlock,
IElement::SpecialBlock,
ISpecialBlock
),
(
organic::types::Element::DynamicBlock,
IElement::DynamicBlock,
IDynamicBlock
),
(
organic::types::Element::FootnoteDefinition,
IElement::FootnoteDefinition,
IFootnoteDefinition
),
(
organic::types::Element::Comment,
IElement::Comment,
IComment
),
(organic::types::Element::Drawer, IElement::Drawer, IDrawer),
(
organic::types::Element::PropertyDrawer,
IElement::PropertyDrawer,
IPropertyDrawer
),
(organic::types::Element::Table, IElement::Table, ITable),
(
organic::types::Element::VerseBlock,
IElement::VerseBlock,
IVerseBlock
),
(
organic::types::Element::CommentBlock,
IElement::CommentBlock,
ICommentBlock
),
(
organic::types::Element::ExampleBlock,
IElement::ExampleBlock,
IExampleBlock
),
(
organic::types::Element::ExportBlock,
IElement::ExportBlock,
IExportBlock
),
(
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
),
)
});