Enum rsass::ScopeRef

source ·
pub enum ScopeRef {
    Builtin(&'static Scope),
    Dynamic(Arc<Scope>),
}
Expand description

A static or dynamic scope referece.

This dereferences to a Scope.

Variants§

§

Builtin(&'static Scope)

The builtin scopes in rsass is static.

§

Dynamic(Arc<Scope>)

All other scopes are dynamic. This uses Arc reference counting.

Implementations§

source§

impl ScopeRef

source

pub fn new_global(format: Format) -> Self

Create a new global scope.

A “global” scope is just a scope that have no parent. There will be multiple global scopes existing during the evaluation of a single sass file.

source

pub fn sub(parent: ScopeRef) -> Self

Create a new subscope of a given parent.

source

pub fn sub_selectors(parent: ScopeRef, selectors: SelectorCtx) -> Self

Create a new subscope of a given parent with selectors.

source

pub fn is_same(a: &Self, b: &Self) -> bool

Check if a and b references the same scope.

source

pub fn eval_body(self, body: &[Item]) -> Result<Option<Value>, Error>
where Self: Sized,

Evaluate a body of items in this scope.

Methods from Deref<Target = Scope>§

source

pub fn define_module(&self, name: String, module: ScopeRef)

Define a module in the scope.

This is used by the @use statement.

source

pub fn get_module(&self, name: &str) -> Option<ScopeRef>

Get a module.

This is used when refering to a function or variable with namespace.name notation.

source

pub fn get_format(&self) -> Format

Get the format used in this scope.

source

pub fn define(&self, name: Name, val: Value) -> Result<(), ScopeError>

Define a none-default, non-global variable.

source

pub fn set_variable( &self, name: Name, val: Value, default: bool, global: bool ) -> Result<(), ScopeError>

Define a variable with a value.

The $ sign is not included in name.

source

pub fn define_global(&self, name: Name, val: Value)

Define a variable in the global scope that is an ultimate parent of this scope.

source

pub fn get_or_none(&self, name: &Name) -> Option<Value>

Get the Value for a variable.

source

pub fn get(&self, name: &Name) -> Result<Value, ScopeError>

Get the value for a variable (or an error).

source

pub fn store_local_values(&self, names: &[Name]) -> Vec<(Name, Option<Value>)>

Copy a set of local variables to a temporary holder

source

pub fn restore_local_values(&self, data: Vec<(Name, Option<Value>)>)

Restore a set of local variables from a temporary holder

source

pub fn get_global_or_none(&self, name: &Name) -> Option<Value>

Get the global Value for a variable.

source

pub fn get_mixin(&self, name: &Name) -> Option<MixinDecl>

Get a mixin by name.

Returns the formal args and the body of the mixin.

source

pub fn define_mixin(&self, name: Name, mixin: MixinDecl)

Define a mixin.

source

pub fn define_function(&self, name: Name, func: Function)

Define a function.

source

pub fn get_function(&self, name: &Name) -> Result<Option<Function>, ScopeError>

Get a function by name.

source

pub fn get_selectors(&self) -> &SelectorCtx

Get the selectors active for this scope.

source

pub fn functions_map(&self) -> Value

Get the functions of this scope as a Value::Map.

source

pub fn variables_map(&self) -> Value

Get the variables of this scope as a Value::Map.

source

pub fn forward(&self) -> ScopeRef

Get the forward scope for this scope.

Create a new one if necessary.

source

pub fn opt_forward(&self) -> Option<ScopeRef>

Get the forward scope for this scope, if any.

Trait Implementations§

source§

impl Clone for ScopeRef

source§

fn clone(&self) -> ScopeRef

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Deref for ScopeRef

§

type Target = Scope

The resulting type after dereferencing.
source§

fn deref(&self) -> &Scope

Dereferences the value.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more