mirror of
https://github.com/TxtDot/dalet-rs.git
synced 2025-03-13 03:04:37 +03:00
refactor: move traits to daletl
This commit is contained in:
parent
accf9aae58
commit
4cc99ce163
4 changed files with 25 additions and 24 deletions
|
@ -1,6 +1,6 @@
|
|||
use num_enum::TryFromPrimitive;
|
||||
|
||||
use crate::daletl::{self, t_new, Tid};
|
||||
use crate::daletl::{self, t_new, Tid, ToDaletl, ToDaletlArgument, ToDaletlBody, ToDaletlTag};
|
||||
|
||||
const NB: daletl::Body = daletl::Body::Null;
|
||||
const NA: daletl::Argument = daletl::Argument::Null;
|
||||
|
@ -39,14 +39,6 @@ pub enum Tag {
|
|||
Pre(String),
|
||||
}
|
||||
|
||||
pub trait ToDaletl {
|
||||
fn to_daletl(self) -> Vec<daletl::Tag>;
|
||||
}
|
||||
|
||||
pub trait ToDaletlTag {
|
||||
fn to_daletl_tag(self) -> daletl::Tag;
|
||||
}
|
||||
|
||||
impl ToDaletlTag for Tag {
|
||||
fn to_daletl_tag(self) -> daletl::Tag {
|
||||
match self {
|
||||
|
@ -84,14 +76,6 @@ impl ToDaletlTag for Tag {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait ToDaletlBody {
|
||||
fn to_daletl_body(self) -> daletl::Body;
|
||||
}
|
||||
|
||||
pub trait ToDaletlArgument {
|
||||
fn to_daletl_argument(self) -> daletl::Argument;
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, TryFromPrimitive)]
|
||||
#[repr(u8)]
|
||||
pub enum HeadingLevel {
|
||||
|
|
|
@ -21,10 +21,6 @@ pub fn t_new(id: Tid, body: Body, argument: Argument) -> Tag {
|
|||
Tag::new(id, body, argument)
|
||||
}
|
||||
|
||||
pub trait IsNull {
|
||||
fn is_null(&self) -> bool;
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
|
||||
#[serde(untagged)]
|
||||
pub enum Body {
|
||||
|
@ -94,3 +90,23 @@ pub enum Tid {
|
|||
Code,
|
||||
Pre,
|
||||
}
|
||||
|
||||
pub trait IsNull {
|
||||
fn is_null(&self) -> bool;
|
||||
}
|
||||
|
||||
pub trait ToDaletl {
|
||||
fn to_daletl(self) -> Vec<Tag>;
|
||||
}
|
||||
|
||||
pub trait ToDaletlTag {
|
||||
fn to_daletl_tag(self) -> Tag;
|
||||
}
|
||||
|
||||
pub trait ToDaletlBody {
|
||||
fn to_daletl_body(self) -> Body;
|
||||
}
|
||||
|
||||
pub trait ToDaletlArgument {
|
||||
fn to_daletl_argument(self) -> Argument;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue