onlytypes-core 0.1.4

Core functionality for onlytypes-rs
Documentation
use crate::*;

#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Strng(String);

impl std::ops::Deref for Strng {
    type Target = String;
    #[inline]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}

impl std::fmt::Debug for Strng {
    #[inline]
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        self.0.fmt(f)
    }
}

impl std::fmt::Display for Strng {
    #[inline]
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        self.0.fmt(f)
    }
}

impl Strng {
    pub fn new() -> Self {
        Strng(String::new())
    }
}

impl From<String> for Strng {
    #[inline]
    fn from(s: String) -> Self {
        Strng(s)
    }
}

impl From<Strng> for String {
    #[inline]
    fn from(s: Strng) -> Self {
        s.0
    }
}

impl From<TokenStream> for Strng {
    #[inline]
    fn from(s: TokenStream) -> Self {
        Strng(s.to_string())
    }
}

impl From<Strng> for TokenStream {
    #[inline]
    fn from(s: Strng) -> Self {
        syn::parse_str(&s.0).unwrap()
    }
}