Starting to define objects based on org-mode's definitions.
This commit is contained in:
parent
36210c2d7f
commit
87c4a955af
@ -4,6 +4,7 @@ mod document;
|
|||||||
mod error;
|
mod error;
|
||||||
mod link;
|
mod link;
|
||||||
mod list;
|
mod list;
|
||||||
|
mod object;
|
||||||
mod paragraph;
|
mod paragraph;
|
||||||
mod parser_context;
|
mod parser_context;
|
||||||
mod parser_with_context;
|
mod parser_with_context;
|
||||||
|
25
src/parser/object.rs
Normal file
25
src/parser/object.rs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
pub enum Object<'s> {
|
||||||
|
TextMarkup(TextMarkup<'s>),
|
||||||
|
PlainText(PlainText<'s>),
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct TextMarkup<'s> {
|
||||||
|
pub source: &'s str,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct PlainText<'s> {
|
||||||
|
pub source: &'s str,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait Source<'s> {
|
||||||
|
fn get_source(&'s self) -> &'s str;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'s> Source<'s> for Object<'s> {
|
||||||
|
fn get_source(&'s self) -> &'s str {
|
||||||
|
match self {
|
||||||
|
Object::TextMarkup(obj) => obj.source,
|
||||||
|
Object::PlainText(obj) => obj.source,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user