use Identifier for SassFunction names

This commit is contained in:
ConnorSkees 2020-05-22 20:13:39 -04:00
parent 2102781f62
commit b4b2edc9a4
2 changed files with 6 additions and 5 deletions

View File

@ -204,9 +204,9 @@ fn get_function(mut args: CallArgs, scope: &Scope, super_selector: &Selector) ->
node: name.clone(), node: name.clone(),
span: args.span(), span: args.span(),
}) { }) {
Ok(f) => SassFunction::UserDefined(Box::new(f), name), Ok(f) => SassFunction::UserDefined(Box::new(f), name.into()),
Err(..) => match GLOBAL_FUNCTIONS.get(name.as_str()) { Err(..) => match GLOBAL_FUNCTIONS.get(name.as_str()) {
Some(f) => SassFunction::Builtin(f.clone(), name), Some(f) => SassFunction::Builtin(f.clone(), name.into()),
None => return Err((format!("Function not found: {}", name), args.span()).into()), None => return Err((format!("Function not found: {}", name), args.span()).into()),
}, },
}; };

View File

@ -14,6 +14,7 @@ use std::fmt;
use crate::args::CallArgs; use crate::args::CallArgs;
use crate::atrule::Function; use crate::atrule::Function;
use crate::builtin::Builtin; use crate::builtin::Builtin;
use crate::common::Identifier;
use crate::error::SassResult; use crate::error::SassResult;
use crate::scope::Scope; use crate::scope::Scope;
use crate::selector::Selector; use crate::selector::Selector;
@ -27,15 +28,15 @@ use crate::value::Value;
/// for use in the builtin function `inspect()` /// for use in the builtin function `inspect()`
#[derive(Clone)] #[derive(Clone)]
pub(crate) enum SassFunction { pub(crate) enum SassFunction {
Builtin(Builtin, String), Builtin(Builtin, Identifier),
UserDefined(Box<Function>, String), UserDefined(Box<Function>, Identifier),
} }
impl SassFunction { impl SassFunction {
/// Get the name of the function referenced /// Get the name of the function referenced
/// ///
/// Used mainly in debugging and `inspect()` /// Used mainly in debugging and `inspect()`
pub fn name(&self) -> &str { pub fn name(&self) -> &Identifier {
match self { match self {
Self::Builtin(_, name) => name, Self::Builtin(_, name) => name,
Self::UserDefined(_, name) => name, Self::UserDefined(_, name) => name,