pub struct LocalAssignStatement { /* private fields */ }
Expand description
Represents a local variable assignment statement.
Implementations§
Source§impl LocalAssignStatement
impl LocalAssignStatement
Sourcepub fn new(variables: Vec<TypedIdentifier>, values: Vec<Expression>) -> Self
pub fn new(variables: Vec<TypedIdentifier>, values: Vec<Expression>) -> Self
Creates a new local assignment statement with the given variables and values.
Sourcepub fn from_variable<S: Into<TypedIdentifier>>(variable: S) -> Self
pub fn from_variable<S: Into<TypedIdentifier>>(variable: S) -> Self
Creates a new local assignment statement with a single variable and no values.
Sourcepub fn with_tokens(self, tokens: LocalAssignTokens) -> Self
pub fn with_tokens(self, tokens: LocalAssignTokens) -> Self
Sets the tokens for this local assignment statement.
Sourcepub fn set_tokens(&mut self, tokens: LocalAssignTokens)
pub fn set_tokens(&mut self, tokens: LocalAssignTokens)
Sets the tokens for this local assignment statement.
Sourcepub fn get_tokens(&self) -> Option<&LocalAssignTokens>
pub fn get_tokens(&self) -> Option<&LocalAssignTokens>
Returns the tokens for this local assignment statement, if any.
Sourcepub fn mutate_tokens(&mut self) -> Option<&mut LocalAssignTokens>
pub fn mutate_tokens(&mut self) -> Option<&mut LocalAssignTokens>
Returns a mutable reference to the tokens, if any.
Sourcepub fn with_variable<S: Into<TypedIdentifier>>(self, variable: S) -> Self
pub fn with_variable<S: Into<TypedIdentifier>>(self, variable: S) -> Self
Adds a variable to this local assignment statement.
Sourcepub fn with_value<E: Into<Expression>>(self, value: E) -> Self
pub fn with_value<E: Into<Expression>>(self, value: E) -> Self
Adds a value to this local assignment statement.
Sourcepub fn into_assignments(self) -> (Vec<TypedIdentifier>, Vec<Expression>)
pub fn into_assignments(self) -> (Vec<TypedIdentifier>, Vec<Expression>)
Converts this statement into a tuple of variables and values.
Sourcepub fn append_assignment<S: Into<TypedIdentifier>>(
&mut self,
variable: S,
value: Expression,
)
pub fn append_assignment<S: Into<TypedIdentifier>>( &mut self, variable: S, value: Expression, )
Adds a new variable-value pair to this local assignment statement.
Sourcepub fn for_each_assignment<F>(&mut self, callback: F)
pub fn for_each_assignment<F>(&mut self, callback: F)
Applies a function to each variable-value pair.
Sourcepub fn get_variables(&self) -> &Vec<TypedIdentifier>
pub fn get_variables(&self) -> &Vec<TypedIdentifier>
Returns the list of variables.
Sourcepub fn iter_variables(&self) -> impl Iterator<Item = &TypedIdentifier>
pub fn iter_variables(&self) -> impl Iterator<Item = &TypedIdentifier>
Returns an iterator over the variables.
Sourcepub fn iter_mut_variables(
&mut self,
) -> impl Iterator<Item = &mut TypedIdentifier>
pub fn iter_mut_variables( &mut self, ) -> impl Iterator<Item = &mut TypedIdentifier>
Returns a mutable iterator over the variables.
Sourcepub fn append_variables(&mut self, variables: &mut Vec<TypedIdentifier>)
pub fn append_variables(&mut self, variables: &mut Vec<TypedIdentifier>)
Appends variables from another vector.
Sourcepub fn extend_values<T: IntoIterator<Item = Expression>>(&mut self, iter: T)
pub fn extend_values<T: IntoIterator<Item = Expression>>(&mut self, iter: T)
Extends the values with elements from an iterator.
Sourcepub fn iter_mut_values(&mut self) -> impl Iterator<Item = &mut Expression>
pub fn iter_mut_values(&mut self) -> impl Iterator<Item = &mut Expression>
Returns a mutable iterator over the values.
Sourcepub fn iter_values(&self) -> impl Iterator<Item = &Expression>
pub fn iter_values(&self) -> impl Iterator<Item = &Expression>
Returns an iterator over the values.
Sourcepub fn push_variable(&mut self, variable: impl Into<TypedIdentifier>)
pub fn push_variable(&mut self, variable: impl Into<TypedIdentifier>)
Adds a variable to this local assignment statement.
Sourcepub fn push_value(&mut self, value: impl Into<Expression>)
pub fn push_value(&mut self, value: impl Into<Expression>)
Adds a value to this local assignment statement.
Sourcepub fn append_values(&mut self, values: &mut Vec<Expression>)
pub fn append_values(&mut self, values: &mut Vec<Expression>)
Appends values from another vector.
Sourcepub fn last_value(&self) -> Option<&Expression>
pub fn last_value(&self) -> Option<&Expression>
Returns the last value, if any.
Sourcepub fn pop_value(&mut self) -> Option<Expression>
pub fn pop_value(&mut self) -> Option<Expression>
Removes and returns the last value, adjusting tokens as needed.
Sourcepub fn remove_value(&mut self, index: usize) -> Option<Expression>
pub fn remove_value(&mut self, index: usize) -> Option<Expression>
Removes and returns the value at the given index, adjusting tokens as needed.
Sourcepub fn remove_variable(&mut self, index: usize) -> Option<TypedIdentifier>
pub fn remove_variable(&mut self, index: usize) -> Option<TypedIdentifier>
Removes and returns the variable at the given index, adjusting tokens as needed.
Returns None if there is only one variable or if the index is out of bounds.
Sourcepub fn values_len(&self) -> usize
pub fn values_len(&self) -> usize
Returns the number of values.
Sourcepub fn variables_len(&self) -> usize
pub fn variables_len(&self) -> usize
Returns the number of variables.
Sourcepub fn has_values(&self) -> bool
pub fn has_values(&self) -> bool
Returns whether this statement has any values.
Sourcepub fn clear_types(&mut self)
pub fn clear_types(&mut self)
Removes type annotations from all variables.
Sourcepub fn mutate_first_token(&mut self) -> &mut Token
pub fn mutate_first_token(&mut self) -> &mut Token
Returns a mutable reference to the first token for this statement, creating it if missing.
Sourcepub fn mutate_last_token(&mut self) -> &mut Token
pub fn mutate_last_token(&mut self) -> &mut Token
Returns a mutable reference to the last token for this statement, creating it if missing.
Sourcepub fn clear_comments(&mut self)
pub fn clear_comments(&mut self)
Clears all comments from the tokens in this node.
Sourcepub fn clear_whitespaces(&mut self)
pub fn clear_whitespaces(&mut self)
Clears all whitespaces information from the tokens in this node.
Trait Implementations§
Source§impl Clone for LocalAssignStatement
impl Clone for LocalAssignStatement
Source§fn clone(&self) -> LocalAssignStatement
fn clone(&self) -> LocalAssignStatement
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for LocalAssignStatement
impl Debug for LocalAssignStatement
Source§impl From<LocalAssignStatement> for Statement
impl From<LocalAssignStatement> for Statement
Source§fn from(assign: LocalAssignStatement) -> Statement
fn from(assign: LocalAssignStatement) -> Statement
Source§impl PartialEq for LocalAssignStatement
impl PartialEq for LocalAssignStatement
impl Eq for LocalAssignStatement
impl StructuralPartialEq for LocalAssignStatement
Auto Trait Implementations§
impl Freeze for LocalAssignStatement
impl RefUnwindSafe for LocalAssignStatement
impl Send for LocalAssignStatement
impl Sync for LocalAssignStatement
impl Unpin for LocalAssignStatement
impl UnwindSafe for LocalAssignStatement
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<I, T> ExtractContext<I, ()> for T
impl<I, T> ExtractContext<I, ()> for T
Source§fn extract_context(self, _original_input: I)
fn extract_context(self, _original_input: I)
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