pub struct IfExpression { /* private fields */ }
Expand description
Represents an if expression.
Implementations§
Source§impl IfExpression
impl IfExpression
Sourcepub fn new<E: Into<Expression>, E2: Into<Expression>, E3: Into<Expression>>(
condition: E,
result: E2,
else_result: E3,
) -> Self
pub fn new<E: Into<Expression>, E2: Into<Expression>, E3: Into<Expression>>( condition: E, result: E2, else_result: E3, ) -> Self
Creates a new if expression with the given condition, result, and else result.
Sourcepub fn with_tokens(self, tokens: IfExpressionTokens) -> Self
pub fn with_tokens(self, tokens: IfExpressionTokens) -> Self
Attaches tokens to this if expression.
Sourcepub fn with_branch<E: Into<Expression>, E2: Into<Expression>>(
self,
condition: E,
result: E2,
) -> Self
pub fn with_branch<E: Into<Expression>, E2: Into<Expression>>( self, condition: E, result: E2, ) -> Self
Adds an elseif branch to this if expression.
Sourcepub fn push_branch(&mut self, branch: ElseIfExpressionBranch)
pub fn push_branch(&mut self, branch: ElseIfExpressionBranch)
Adds an elseif branch to this if expression.
Sourcepub fn set_tokens(&mut self, tokens: IfExpressionTokens)
pub fn set_tokens(&mut self, tokens: IfExpressionTokens)
Attaches tokens to this if expression.
Sourcepub fn get_tokens(&self) -> Option<&IfExpressionTokens>
pub fn get_tokens(&self) -> Option<&IfExpressionTokens>
Returns a reference to the tokens attached to this if expression, if any.
Sourcepub fn get_condition(&self) -> &Expression
pub fn get_condition(&self) -> &Expression
Returns a reference to the condition of this if expression.
Sourcepub fn mutate_condition(&mut self) -> &mut Expression
pub fn mutate_condition(&mut self) -> &mut Expression
Returns a mutable reference to the condition of this if expression.
Sourcepub fn get_result(&self) -> &Expression
pub fn get_result(&self) -> &Expression
Returns a reference to the result of this if expression (returned when condition is true).
Sourcepub fn mutate_result(&mut self) -> &mut Expression
pub fn mutate_result(&mut self) -> &mut Expression
Returns a mutable reference to the result of this if expression.
Sourcepub fn get_else_result(&self) -> &Expression
pub fn get_else_result(&self) -> &Expression
Returns a reference to the else result of this if expression.
Sourcepub fn mutate_else_result(&mut self) -> &mut Expression
pub fn mutate_else_result(&mut self) -> &mut Expression
Returns a mutable reference to the else result of this if expression.
Sourcepub fn has_elseif_branch(&self) -> bool
pub fn has_elseif_branch(&self) -> bool
Returns whether this if expression has any elseif branches.
Sourcepub fn iter_branches(&self) -> impl Iterator<Item = &ElseIfExpressionBranch>
pub fn iter_branches(&self) -> impl Iterator<Item = &ElseIfExpressionBranch>
Returns an iterator over the elseif branches of this if expression.
Sourcepub fn clear_elseif_branches(&mut self)
pub fn clear_elseif_branches(&mut self)
Removes all elseif branches from this if expression.
Sourcepub fn retain_elseif_branches_mut(
&mut self,
filter: impl FnMut(&mut ElseIfExpressionBranch) -> bool,
)
pub fn retain_elseif_branches_mut( &mut self, filter: impl FnMut(&mut ElseIfExpressionBranch) -> bool, )
Retains only the elseif branches that satisfy the predicate.
Sourcepub fn remove_branch(&mut self, index: usize) -> Option<ElseIfExpressionBranch>
pub fn remove_branch(&mut self, index: usize) -> Option<ElseIfExpressionBranch>
Removes an elseif branch at the specified index and returns it.
Sourcepub fn iter_mut_branches(
&mut self,
) -> impl Iterator<Item = &mut ElseIfExpressionBranch>
pub fn iter_mut_branches( &mut self, ) -> impl Iterator<Item = &mut ElseIfExpressionBranch>
Returns a mutable iterator over the elseif branches of this if expression.
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 if expression, 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 if expression, 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 IfExpression
impl Clone for IfExpression
Source§fn clone(&self) -> IfExpression
fn clone(&self) -> IfExpression
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for IfExpression
impl Debug for IfExpression
Source§impl From<IfExpression> for Expression
impl From<IfExpression> for Expression
Source§fn from(if_expression: IfExpression) -> Expression
fn from(if_expression: IfExpression) -> Expression
Source§impl PartialEq for IfExpression
impl PartialEq for IfExpression
impl Eq for IfExpression
impl StructuralPartialEq for IfExpression
Auto Trait Implementations§
impl Freeze for IfExpression
impl RefUnwindSafe for IfExpression
impl Send for IfExpression
impl Sync for IfExpression
impl Unpin for IfExpression
impl UnwindSafe for IfExpression
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