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
sourceimpl ScopeRef
impl ScopeRef
sourcepub fn new_global(format: Format) -> Self
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.
sourcepub fn sub_selectors(parent: ScopeRef, selectors: Selectors) -> Self
pub fn sub_selectors(parent: ScopeRef, selectors: Selectors) -> Self
Create a new subscope of a given parent with selectors.
Methods from Deref<Target = Scope>
sourcepub fn define_module(&self, name: String, module: ScopeRef)
pub fn define_module(&self, name: String, module: ScopeRef)
Define a module in the scope.
This is used by the @use
statement.
sourcepub fn get_module(&self, name: &str) -> Option<ScopeRef>
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.
sourcepub fn get_format(&self) -> Format
pub fn get_format(&self) -> Format
Get the format used in this scope.
sourcepub fn set_variable(&self, name: Name, val: Value, default: bool, global: bool)
pub fn set_variable(&self, name: Name, val: Value, default: bool, global: bool)
Define a variable with a value.
The $
sign is not included in name
.
sourcepub fn define_global(&self, name: Name, val: Value)
pub fn define_global(&self, name: Name, val: Value)
Define a variable in the global scope that is an ultimate parent of this scope.
sourcepub fn define_multi(&self, names: &[Name], value: &Value)
pub fn define_multi(&self, names: &[Name], value: &Value)
Define multiple names from a value that is a list. Special case: in names is a single name, value is used directly.
sourcepub fn get_or_none(&self, name: &Name) -> Option<Value>
pub fn get_or_none(&self, name: &Name) -> Option<Value>
Get the Value for a variable.
sourcepub fn get(&self, name: &Name) -> Result<Value, ScopeError>
pub fn get(&self, name: &Name) -> Result<Value, ScopeError>
Get the value for a variable (or an error).
sourcepub fn store_local_values(&self, names: &[Name]) -> Vec<(Name, Option<Value>)>
pub fn store_local_values(&self, names: &[Name]) -> Vec<(Name, Option<Value>)>
Copy a set of local variables to a temporary holder
sourcepub fn restore_local_values(&self, data: Vec<(Name, Option<Value>)>)
pub fn restore_local_values(&self, data: Vec<(Name, Option<Value>)>)
Restore a set of local variables from a temporary holder
sourcepub fn get_global_or_none(&self, name: &Name) -> Option<Value>
pub fn get_global_or_none(&self, name: &Name) -> Option<Value>
Get the global Value for a variable.
sourcepub fn get_mixin(&self, name: &Name) -> Option<MixinDecl>
pub fn get_mixin(&self, name: &Name) -> Option<MixinDecl>
Get a mixin by name.
Returns the formal args and the body of the mixin.
sourcepub fn define_mixin(&self, name: Name, mixin: MixinDecl)
pub fn define_mixin(&self, name: Name, mixin: MixinDecl)
Define a mixin.
sourcepub fn define_function(&self, name: Name, func: Function)
pub fn define_function(&self, name: Name, func: Function)
Define a function.
sourcepub fn get_function(&self, name: &Name) -> Result<Option<Function>, Error>
pub fn get_function(&self, name: &Name) -> Result<Option<Function>, Error>
Get a function by name.
sourcepub fn get_selectors(&self) -> &Selectors
pub fn get_selectors(&self) -> &Selectors
Get the selectors active for this scope.
sourcepub fn functions_map(&self) -> Value
pub fn functions_map(&self) -> Value
Get the functions of this scope as a Value::Map
.
sourcepub fn variables_map(&self) -> Value
pub fn variables_map(&self) -> Value
Get the variables of this scope as a Value::Map
.
sourcepub fn forward(&self) -> ScopeRef
pub fn forward(&self) -> ScopeRef
Get the forward scope for this scope.
Create a new one if necessary.
sourcepub fn opt_forward(&self) -> Option<ScopeRef>
pub fn opt_forward(&self) -> Option<ScopeRef>
Get the forward scope for this scope.
Create a new one if necessary.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for ScopeRef
impl Send for ScopeRef
impl Sync for ScopeRef
impl Unpin for ScopeRef
impl UnwindSafe for ScopeRef
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more