pub struct EnvironmentAnalyzer { /* private fields */ }Expand description
Environment analyzer to detect which variables need to be captured
Implementations§
Source§impl EnvironmentAnalyzer
impl EnvironmentAnalyzer
pub fn new() -> Self
Sourcepub fn enter_scope(&mut self)
pub fn enter_scope(&mut self)
Enter a new scope
Sourcepub fn exit_scope(&mut self)
pub fn exit_scope(&mut self)
Exit the current scope
Sourcepub fn define_variable(&mut self, name: &str)
pub fn define_variable(&mut self, name: &str)
Record that a variable is defined in the current scope
Sourcepub fn check_variable_reference(&mut self, name: &str)
pub fn check_variable_reference(&mut self, name: &str)
Check if a variable reference needs to be captured.
Only variables defined OUTSIDE the current function (below function_scope_level)
need capturing. Variables in the same function but in an outer block scope
(e.g., defined before an if/while/for block) are just local variables.
Sourcepub fn mark_capture_mutated(&mut self, name: &str)
pub fn mark_capture_mutated(&mut self, name: &str)
Mark a captured variable as mutated (assigned to inside the closure).
Sourcepub fn get_captured_vars(&self) -> Vec<String>
pub fn get_captured_vars(&self) -> Vec<String>
Get the list of variables that need to be captured
Sourcepub fn get_mutated_captures(&self) -> HashSet<String>
pub fn get_mutated_captures(&self) -> HashSet<String>
Get the set of captured variables that are mutated inside the closure
Sourcepub fn analyze_function(
function: &FunctionDef,
outer_scope_vars: &[String],
) -> Vec<String>
pub fn analyze_function( function: &FunctionDef, outer_scope_vars: &[String], ) -> Vec<String>
Analyze a function to determine which variables it captures
Sourcepub fn analyze_function_with_mutability(
function: &FunctionDef,
outer_scope_vars: &[String],
) -> (Vec<String>, HashSet<String>)
pub fn analyze_function_with_mutability( function: &FunctionDef, outer_scope_vars: &[String], ) -> (Vec<String>, HashSet<String>)
Analyze a function to determine which variables it captures and which are mutated.
Returns (captured_vars, mutated_captures).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for EnvironmentAnalyzer
impl RefUnwindSafe for EnvironmentAnalyzer
impl Send for EnvironmentAnalyzer
impl Sync for EnvironmentAnalyzer
impl Unpin for EnvironmentAnalyzer
impl UnsafeUnpin for EnvironmentAnalyzer
impl UnwindSafe for EnvironmentAnalyzer
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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>
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