Minor refactors.
This commit is contained in:
@@ -150,9 +150,10 @@ impl AST {
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub fn source(&self) -> Option<&str> {
|
||||
match self.source.as_str() {
|
||||
"" => None,
|
||||
s => Some(s),
|
||||
if self.source.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(self.source.as_str())
|
||||
}
|
||||
}
|
||||
/// Get a reference to the source.
|
||||
|
@@ -89,6 +89,26 @@ pub struct ConditionalStmtBlock {
|
||||
pub statements: StmtBlock,
|
||||
}
|
||||
|
||||
impl<B: Into<StmtBlock>> From<B> for ConditionalStmtBlock {
|
||||
#[inline(always)]
|
||||
fn from(value: B) -> Self {
|
||||
Self {
|
||||
condition: None,
|
||||
statements: value.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<B: Into<StmtBlock>> From<(Expr, B)> for ConditionalStmtBlock {
|
||||
#[inline(always)]
|
||||
fn from(value: (Expr, B)) -> Self {
|
||||
Self {
|
||||
condition: Some(value.0),
|
||||
statements: value.1.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<B: Into<StmtBlock>> From<(Option<Expr>, B)> for ConditionalStmtBlock {
|
||||
#[inline(always)]
|
||||
fn from(value: (Option<Expr>, B)) -> Self {
|
||||
|
Reference in New Issue
Block a user