feat!: introduce SASS prelude as well. Its more convenient then making build.rs sassy macro.

This commit is contained in:
Yiffy Dev 2024-11-02 01:33:28 +05:00 • committed by spushk
commit ed6cdd02f7
Signed by: spushk
GPG key ID: 7797B761E105E8AA

View file

@ -117,6 +117,17 @@ impl ToTokens for ArbitraryStyleSyntax {
}
}
impl TryFrom<&str> for ArbitraryStyleSyntax {
type Error = ();
fn try_from(value: &str) -> Result<Self, Self::Error> {
match value {
"sass" => Ok(Self::Sass),
"scss" => Ok(Self::Scss),
_ => Err(())
}
}
}
impl Parse for ArbitraryStyleSyntax {
fn parse(input: syn::parse::ParseStream) -> syn::Result<Self> {
match input.parse::<Token![:]>() {
@ -128,10 +139,9 @@ impl Parse for ArbitraryStyleSyntax {
}
let ident = input.parse::<Ident>()?;
match ident.to_string().as_str() {
"sass" => Ok(Self::Sass),
"scss" => Ok(Self::Scss),
_ => Err(syn::Error::new(
match Self::try_from(ident.to_string().as_str()) {
Ok(v) => Ok(v),
Err(_) => Err(syn::Error::new(
ident.span(),
format!(
"Available syntax are `sass` and `scss`, omit to use default {:?} syntax",