Skip to content

Conversation

sodiumjoe
Copy link

branched from #77

@jondlm
Copy link

jondlm commented Jul 1, 2024

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.

@LegNeato LegNeato requested a review from tailhook July 11, 2024 22:22
@LegNeato
Copy link
Member

@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")]
Copy link
Member

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>;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants