-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Serde Support For AST #80
base: master
Are you sure you want to change the base?
Conversation
Any chance we could get this merged/released soon? I understand if y'all are busy. I'll begin the process of forking internally but ideally we can unwind that soon. |
@tailhook Can you take a look? |
|
||
use crate::helpers::{ident, kind, name, punct}; | ||
use crate::position::Pos; | ||
use crate::tokenizer::{Kind as T, Token, TokenStream}; | ||
|
||
#[cfg(feature = "serde")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this is a good idea, but I think to not duplicate everything you could do something like:
#[cfg(feature = "serde")]
mod text_traits {
use serde::{Serialize, Deserialize};
pub trait SerdeTraits<'a>: Serialize + Deserialize<'a> {}
impl<'a, T> SerdeTraits<'a> for T where T: Serialize + Deserialize<'a> {}
}
#[cfg(not(feature = "serde"))]
mod text_traits {
pub trait SerdeTraits<'a> {}
impl<'a, T> SerdeTraits<'a> for T {}
}
// Define the main trait with conditional compilation
pub trait Text<'a>: 'a {
type Value: 'a
+ From<&'a str>
+ AsRef<str>
+ std::borrow::Borrow<str>
+ PartialEq
+ Eq
+ PartialOrd
+ Ord
+ fmt::Debug
+ Clone
+ text_traits::SerdeTraits<'a>;
}
branched from #77