Move AstNode into the types crate.

Now that it is used for more than just iteration, it makes sense to promote it to the types crate.
This commit is contained in:
Tom Alexander 2023-10-02 13:10:45 -04:00
parent 25f664e69e
commit a62c3fc522
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
11 changed files with 21 additions and 21 deletions

View File

@ -12,7 +12,7 @@ use super::util::get_property;
use super::util::get_property_boolean;
use super::util::get_property_quoted_string;
use super::util::get_property_unquoted_atom;
use crate::iter::AstNode;
use crate::types::AstNode;
use crate::types::AngleLink;
use crate::types::BabelCall;
use crate::types::Bold;

View File

@ -1,6 +1,6 @@
use std::borrow::Cow;
use crate::iter::AstNode;
use crate::types::AstNode;
use crate::types::AngleLink;
use crate::types::BabelCall;
use crate::types::Bold;

View File

@ -1,7 +1,7 @@
use std::collections::VecDeque;
use super::ast_node::AstNode;
use super::ast_node_iter::AstNodeIter;
use crate::types::AstNode;
pub struct AllAstNodeIter<'r, 's> {
root: Option<AstNode<'r, 's>>,

View File

@ -1,10 +1,10 @@
use std::marker::PhantomData;
use super::ast_node::AstNode;
use super::macros::children_iter;
use super::macros::empty_iter;
use super::macros::multi_field_iter;
use crate::types::AngleLink;
use crate::types::AstNode;
use crate::types::BabelCall;
use crate::types::Bold;
use crate::types::Citation;

View File

@ -1,16 +1,3 @@
/// Write the implementation of From<> to convert a borrow of the type to an AstNode
macro_rules! to_ast_node {
($inp:ty, $enum:expr) => {
impl<'r, 's> From<$inp> for AstNode<'r, 's> {
fn from(value: $inp) -> Self {
$enum(value)
}
}
};
}
pub(crate) use to_ast_node;
/// Create iterators for ast nodes where it only has to iterate over children
macro_rules! children_iter {
($astnodetype:ty, $itertype:ident, $innertype:ty) => {

View File

@ -1,5 +1,3 @@
mod all_ast_node_iter;
mod ast_node;
mod ast_node_iter;
mod macros;
pub(crate) use ast_node::AstNode;

View File

@ -20,7 +20,7 @@ use crate::context::RefContext;
use crate::error::CustomError;
use crate::error::MyError;
use crate::error::Res;
use crate::iter::AstNode;
use crate::types::AstNode;
use crate::parser::org_source::convert_error;
use crate::parser::util::blank_line;
use crate::types::Document;

View File

@ -11,7 +11,7 @@ use super::OrgSource;
use crate::context::HeadlineLevelFilter;
use crate::error::CustomError;
use crate::error::Res;
use crate::iter::AstNode;
use crate::types::AstNode;
use crate::settings::GlobalSettings;
use crate::types::Document;
use crate::types::Keyword;

12
src/types/macros.rs Normal file
View File

@ -0,0 +1,12 @@
/// Write the implementation of From<> to convert a borrow of the type to an AstNode
macro_rules! to_ast_node {
($inp:ty, $enum:expr) => {
impl<'r, 's> From<$inp> for AstNode<'r, 's> {
fn from(value: $inp) -> Self {
$enum(value)
}
}
};
}
pub(crate) use to_ast_node;

View File

@ -1,11 +1,14 @@
mod ast_node;
mod document;
mod element;
mod get_standard_properties;
mod greater_element;
mod lesser_element;
mod macros;
mod object;
mod source;
mod standard_properties;
pub(crate) use ast_node::AstNode;
pub use document::Document;
pub use document::DocumentElement;
pub use document::Heading;