use std::fmt::Display;
#[derive(Debug, PartialEq, Eq)]
pub enum FormatError {
TrimError,
}
#[derive(Debug)]
pub struct FormattedType(pub String);
impl Display for FormattedType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.0)
}
}
pub trait TrimFunctions
where
Self: Display + From<String>,
{
fn trim_export(&self) -> Self {
Self::from(self.to_string().replace("export ", ""))
}
fn remove_type_word(&self) -> Self {
Self::from(self.to_string().replace("type ", ""))
}
fn replace_equals(&self) -> Self {
Self::from(self.to_string().replace(" =", ""))
}
}
impl From<String> for FormattedType {
fn from(value: String) -> Self {
Self(value)
}
}
impl TrimFunctions for FormattedType {}