Rename value/function.rs to value/sass_function.rs

This is to faciliate the addition of src/value/css_function.rs and the
inclusion of a special type `CssFunction` which represents a plain css
function.
This commit is contained in:
ConnorSkees 2020-04-04 18:55:59 -04:00
parent b7be1705a2
commit b44c064481
2 changed files with 24 additions and 2 deletions

View File

@ -7,11 +7,11 @@ use crate::common::{Brackets, ListSeparator, Op, QuoteKind};
use crate::error::SassResult;
use crate::unit::{Unit, UNIT_CONVERSION_TABLE};
pub(crate) use function::SassFunction;
pub(crate) use sass_function::SassFunction;
pub(crate) use map::SassMap;
pub(crate) use number::Number;
mod function;
mod sass_function;
mod map;
mod number;
mod ops;

View File

@ -1,3 +1,14 @@
//! SASS functions are those that are evaluated and return a value
//!
//! SASS functions can be either user-defined or builtin.
//!
//! User-defined functions are those that have been implemented in SASS
//! using the @function rule. See the documentation of `crate::atrule::Function`
//! for more information.
//!
//! Builtin functions are those that have been implemented in rust and are
//! in the global scope.
use std::fmt;
use crate::args::CallArgs;
@ -8,6 +19,11 @@ use crate::scope::Scope;
use crate::selector::Selector;
use crate::value::Value;
/// A SASS function
/// See toplevel documentation for more information
///
/// The function name is stored in addition to the body
/// for use in the builtin function `inspect()`
#[derive(Clone)]
pub(crate) enum SassFunction {
Builtin(Builtin, String),
@ -15,6 +31,9 @@ pub(crate) enum SassFunction {
}
impl SassFunction {
/// Get the name of the function referenced
///
/// Used mainly in debugging and `inspect()`
pub fn name(&self) -> &str {
match self {
Self::Builtin(_, name) => name,
@ -22,6 +41,9 @@ impl SassFunction {
}
}
/// Whether the function is builtin or user-defined
///
/// Used only in `std::fmt::Debug` for `SassFunction`
fn kind(&self) -> &'static str {
match &self {
Self::Builtin(..) => "Builtin",