pub struct VariableScope {
pub name: String,
pub created_at: SystemTime,
/* private fields */
}
Expand description
变量作用域
Fields§
§name: String
作用域名称
created_at: SystemTime
创建时间
Implementations§
Source§impl VariableScope
impl VariableScope
Sourcepub fn create_child(&self, name: String) -> Self
pub fn create_child(&self, name: String) -> Self
创建子作用域
Sourcepub fn define_variable(
&mut self,
name: String,
value: Expression,
defined_in: CellId,
) -> NotebookResult<()>
pub fn define_variable( &mut self, name: String, value: Expression, defined_in: CellId, ) -> NotebookResult<()>
定义变量
Sourcepub fn define_constant(
&mut self,
name: String,
value: Expression,
defined_in: CellId,
) -> NotebookResult<()>
pub fn define_constant( &mut self, name: String, value: Expression, defined_in: CellId, ) -> NotebookResult<()>
定义常量
Sourcepub fn update_variable(
&mut self,
name: &str,
value: Expression,
updated_in: CellId,
) -> NotebookResult<()>
pub fn update_variable( &mut self, name: &str, value: Expression, updated_in: CellId, ) -> NotebookResult<()>
更新变量值
Sourcepub fn get_variable(&mut self, name: &str) -> Option<&mut VariableBinding>
pub fn get_variable(&mut self, name: &str) -> Option<&mut VariableBinding>
获取变量值
Sourcepub fn has_variable(&self, name: &str) -> bool
pub fn has_variable(&self, name: &str) -> bool
检查变量是否存在
Sourcepub fn remove_variable(&mut self, name: &str) -> NotebookResult<VariableBinding>
pub fn remove_variable(&mut self, name: &str) -> NotebookResult<VariableBinding>
删除变量
Sourcepub fn get_variable_names(&self) -> Vec<String>
pub fn get_variable_names(&self) -> Vec<String>
获取所有变量名
Sourcepub fn get_local_variables(&self) -> &HashMap<String, VariableBinding>
pub fn get_local_variables(&self) -> &HashMap<String, VariableBinding>
获取本地变量(不包括父作用域)
Sourcepub fn statistics(&self) -> ScopeStatistics
pub fn statistics(&self) -> ScopeStatistics
获取变量统计信息
Sourcepub fn export_for_computation(&mut self) -> HashMap<String, Number>
pub fn export_for_computation(&mut self) -> HashMap<String, Number>
导出变量到 HashMap(用于计算引擎)
Trait Implementations§
Source§impl Clone for VariableScope
impl Clone for VariableScope
Source§fn clone(&self) -> VariableScope
fn clone(&self) -> VariableScope
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for VariableScope
impl Debug for VariableScope
Source§impl<'de> Deserialize<'de> for VariableScope
impl<'de> Deserialize<'de> for VariableScope
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for VariableScope
impl RefUnwindSafe for VariableScope
impl Send for VariableScope
impl Sync for VariableScope
impl Unpin for VariableScope
impl UnwindSafe for VariableScope
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more