pub struct ScopeManager { /* private fields */ }Expand description
作用域管理器
Implementations§
Source§impl ScopeManager
impl ScopeManager
Sourcepub fn create_cell_scope(&mut self, cell_id: CellId, name: String)
pub fn create_cell_scope(&mut self, cell_id: CellId, name: String)
创建单元格作用域
Sourcepub fn set_current_scope(&mut self, cell_id: Option<CellId>)
pub fn set_current_scope(&mut self, cell_id: Option<CellId>)
设置当前作用域
Sourcepub fn get_current_scope(&mut self) -> &mut VariableScope
pub fn get_current_scope(&mut self) -> &mut VariableScope
获取当前作用域
Sourcepub fn get_global_scope(&mut self) -> &mut VariableScope
pub fn get_global_scope(&mut self) -> &mut VariableScope
获取全局作用域
Sourcepub fn get_cell_scope(&mut self, cell_id: &CellId) -> Option<&mut VariableScope>
pub fn get_cell_scope(&mut self, cell_id: &CellId) -> Option<&mut VariableScope>
获取指定单元格的作用域
Sourcepub fn define_global_variable(
&mut self,
name: String,
value: Expression,
defined_in: CellId,
) -> NotebookResult<()>
pub fn define_global_variable( &mut self, name: String, value: Expression, defined_in: CellId, ) -> NotebookResult<()>
定义全局变量
Sourcepub fn define_global_constant(
&mut self,
name: String,
value: Expression,
defined_in: CellId,
) -> NotebookResult<()>
pub fn define_global_constant( &mut self, name: String, value: Expression, defined_in: CellId, ) -> NotebookResult<()>
定义全局常量
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 get_visible_variables(&self) -> Vec<String>
pub fn get_visible_variables(&self) -> Vec<String>
获取所有可见的变量名
Sourcepub fn clear_cell_scope(&mut self, cell_id: &CellId)
pub fn clear_cell_scope(&mut self, cell_id: &CellId)
清除单元格作用域
Sourcepub fn export_for_computation(&mut self) -> HashMap<String, Number>
pub fn export_for_computation(&mut self) -> HashMap<String, Number>
导出变量用于计算
Sourcepub fn statistics(&self) -> ManagerStatistics
pub fn statistics(&self) -> ManagerStatistics
获取作用域管理器统计信息
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ScopeManager
impl RefUnwindSafe for ScopeManager
impl Send for ScopeManager
impl Sync for ScopeManager
impl Unpin for ScopeManager
impl UnsafeUnpin for ScopeManager
impl UnwindSafe for ScopeManager
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> 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