Struct valkyrie_ast::GuardStatement
source · pub struct GuardStatement {
pub negative: bool,
pub condition: ExpressionNode,
pub main_body: GuardPattern,
pub span: Range<u32>,
}Expand description
guard a > 0 { ... }
The else block must use control.
assert a > 0 {
panic!("a must be greater than 0");
}
assert let Some(a) = b {
panic!("b must be Some");
}
if a < 0 {
return error;
}
do_something_else();
guard let Failure(error) = e if xxx then { ... }
The else block must use control.
if e.is_failure() {
let error = x.as_failure();
return error;
}
do_something_else();
Fields§
§negative: boolThe condition to check
condition: ExpressionNodeThe condition to check
main_body: GuardPatternsame as if condition
span: Range<u32>The range of the node
Trait Implementations§
source§impl Clone for GuardStatement
impl Clone for GuardStatement
source§fn clone(&self) -> GuardStatement
fn clone(&self) -> GuardStatement
Returns a copy 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 GuardStatement
impl Debug for GuardStatement
source§impl From<GuardStatement> for ExpressionKind
impl From<GuardStatement> for ExpressionKind
source§fn from(o: GuardStatement) -> Self
fn from(o: GuardStatement) -> Self
Converts to this type from the input type.
source§impl From<GuardStatement> for StatementKind
impl From<GuardStatement> for StatementKind
source§fn from(o: GuardStatement) -> Self
fn from(o: GuardStatement) -> Self
Converts to this type from the input type.
source§impl Hash for GuardStatement
impl Hash for GuardStatement
source§impl PartialEq for GuardStatement
impl PartialEq for GuardStatement
source§fn eq(&self, other: &GuardStatement) -> bool
fn eq(&self, other: &GuardStatement) -> bool
This method tests for
self and other values to be equal, and is used
by ==.source§impl ValkyrieNode for GuardStatement
impl ValkyrieNode for GuardStatement
impl Eq for GuardStatement
impl StructuralPartialEq for GuardStatement
Auto Trait Implementations§
impl RefUnwindSafe for GuardStatement
impl Send for GuardStatement
impl Sync for GuardStatement
impl Unpin for GuardStatement
impl UnwindSafe for GuardStatement
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