Use .. for (_).

This commit is contained in:
Stephen Chung
2022-02-08 09:46:14 +08:00
parent 97a8fd3d5b
commit 7686ca619a
24 changed files with 155 additions and 149 deletions

View File

@@ -449,7 +449,7 @@ impl AST {
/// foo("!")
/// "#)?;
///
/// // Merge 'ast2', picking only 'error()' but not 'foo(_)', into 'ast1'
/// // Merge 'ast2', picking only 'error()' but not 'foo(..)', into 'ast1'
/// let ast = ast1.merge_filtered(&ast2, |_, _, script, name, params|
/// script && name == "error" && params == 0);
///
@@ -551,7 +551,7 @@ impl AST {
/// foo("!")
/// "#)?;
///
/// // Combine 'ast2', picking only 'error()' but not 'foo(_)', into 'ast1'
/// // Combine 'ast2', picking only 'error()' but not 'foo(..)', into 'ast1'
/// ast1.combine_filtered(ast2, |_, _, script, name, params|
/// script && name == "error" && params == 0);
///
@@ -613,7 +613,7 @@ impl AST {
/// fn bar() { print("hello"); }
/// "#)?;
///
/// // Remove all functions except 'foo(_)'
/// // Remove all functions except 'foo(..)'
/// ast.retain_functions(|_, _, name, params| name == "foo" && params == 1);
/// # }
/// # Ok(())

View File

@@ -450,7 +450,7 @@ impl fmt::Debug for Expr {
Self::FloatConstant(value, ..) => write!(f, "{:?}", value),
Self::CharConstant(value, ..) => write!(f, "{:?}", value),
Self::StringConstant(value, ..) => write!(f, "{:?}", value),
Self::Unit(_) => f.write_str("()"),
Self::Unit(..) => f.write_str("()"),
Self::InterpolatedString(x, ..) => {
f.write_str("InterpolatedString")?;
@@ -535,7 +535,7 @@ impl Expr {
Self::CharConstant(x, ..) => (*x).into(),
Self::StringConstant(x, ..) => x.clone().into(),
Self::BoolConstant(x, ..) => (*x).into(),
Self::Unit(_) => Dynamic::UNIT,
Self::Unit(..) => Dynamic::UNIT,
#[cfg(not(feature = "no_index"))]
Self::Array(x, ..) if self.is_constant() => {
@@ -772,7 +772,7 @@ impl Expr {
#[inline(always)]
#[must_use]
pub const fn is_unit(&self) -> bool {
matches!(self, Self::Unit(_))
matches!(self, Self::Unit(..))
}
/// Is the expression a constant?
#[inline]
@@ -787,7 +787,7 @@ impl Expr {
| Self::IntegerConstant(..)
| Self::CharConstant(..)
| Self::StringConstant(..)
| Self::Unit(_)
| Self::Unit(..)
| Self::Stack(..) => true,
Self::InterpolatedString(x, ..) | Self::Array(x, ..) => x.iter().all(Self::is_constant),
@@ -816,13 +816,13 @@ impl Expr {
| Self::CharConstant(..)
| Self::And(..)
| Self::Or(..)
| Self::Unit(_) => false,
| Self::Unit(..) => false,
Self::IntegerConstant(..)
| Self::StringConstant(..)
| Self::InterpolatedString(..)
| Self::FnCall(..)
| Self::Stmt(_)
| Self::Stmt(..)
| Self::Dot(..)
| Self::Index(..)
| Self::Array(..)

View File

@@ -404,7 +404,7 @@ impl Stmt {
#[inline(always)]
#[must_use]
pub const fn is_noop(&self) -> bool {
matches!(self, Self::Noop(_))
matches!(self, Self::Noop(..))
}
/// Get the [position][Position] of this statement.
#[must_use]
@@ -432,7 +432,7 @@ impl Stmt {
Self::Export(.., pos) => *pos,
#[cfg(not(feature = "no_closure"))]
Self::Share(_) => Position::NONE,
Self::Share(..) => Position::NONE,
}
}
/// Override the [position][Position] of this statement.
@@ -462,7 +462,7 @@ impl Stmt {
Self::Export(.., pos) => *pos = new_pos,
#[cfg(not(feature = "no_closure"))]
Self::Share(_) => (),
Self::Share(..) => (),
}
self
@@ -474,10 +474,10 @@ impl Stmt {
Self::If(..)
| Self::Switch(..)
| Self::Block(..)
| Self::Expr(_)
| Self::Expr(..)
| Self::FnCall(..) => true,
Self::Noop(_) | Self::While(..) | Self::Do(..) | Self::For(..) | Self::TryCatch(..) => {
Self::Noop(..) | Self::While(..) | Self::Do(..) | Self::For(..) | Self::TryCatch(..) => {
false
}
@@ -487,7 +487,7 @@ impl Stmt {
Self::Import(..) | Self::Export(..) => false,
#[cfg(not(feature = "no_closure"))]
Self::Share(_) => false,
Self::Share(..) => false,
}
}
/// Is this statement self-terminated (i.e. no need for a semicolon terminator)?
@@ -502,13 +502,13 @@ impl Stmt {
| Self::TryCatch(..) => true,
// A No-op requires a semicolon in order to know it is an empty statement!
Self::Noop(_) => false,
Self::Noop(..) => false,
Self::Expr(Expr::Custom(x, ..)) if x.is_self_terminated() => true,
Self::Var(..)
| Self::Assignment(..)
| Self::Expr(_)
| Self::Expr(..)
| Self::FnCall(..)
| Self::Do(..)
| Self::BreakLoop(..)
@@ -518,7 +518,7 @@ impl Stmt {
Self::Import(..) | Self::Export(..) => false,
#[cfg(not(feature = "no_closure"))]
Self::Share(_) => false,
Self::Share(..) => false,
}
}
/// Is this statement _pure_?
@@ -527,7 +527,7 @@ impl Stmt {
#[must_use]
pub fn is_pure(&self) -> bool {
match self {
Self::Noop(_) => true,
Self::Noop(..) => true,
Self::Expr(expr) => expr.is_pure(),
Self::If(condition, x, ..) => {
condition.is_pure()
@@ -575,7 +575,7 @@ impl Stmt {
Self::Export(..) => false,
#[cfg(not(feature = "no_closure"))]
Self::Share(_) => false,
Self::Share(..) => false,
}
}
/// Does this statement's behavior depend on its containing block?