Simplify using ..

This commit is contained in:
Stephen Chung
2022-02-08 09:02:15 +08:00
parent 187a20fd8b
commit f8cee0fe4e
54 changed files with 1184 additions and 1190 deletions

View File

@@ -271,7 +271,7 @@ impl Debugger {
} else {
DebuggerStatus::CONTINUE
},
state: if let Some((ref init, _)) = engine.debugger {
state: if let Some((ref init, ..)) = engine.debugger {
init()
} else {
Dynamic::UNIT
@@ -348,8 +348,8 @@ impl Debugger {
self.break_points()
.iter()
.enumerate()
.filter(|&(_, bp)| bp.is_enabled())
.find(|&(_, bp)| match bp {
.filter(|&(.., bp)| bp.is_enabled())
.find(|&(.., bp)| match bp {
#[cfg(not(feature = "no_position"))]
BreakPoint::AtPosition { pos, .. } if pos.is_none() => false,
#[cfg(not(feature = "no_position"))]
@@ -361,26 +361,26 @@ impl Debugger {
node.position() == *pos && _src == source
}
BreakPoint::AtFunctionName { name, .. } => match node {
ASTNode::Expr(Expr::FnCall(x, _))
| ASTNode::Stmt(Stmt::FnCall(x, _))
| ASTNode::Stmt(Stmt::Expr(Expr::FnCall(x, _))) => x.name == *name,
ASTNode::Expr(Expr::FnCall(x, ..))
| ASTNode::Stmt(Stmt::FnCall(x, ..))
| ASTNode::Stmt(Stmt::Expr(Expr::FnCall(x, ..))) => x.name == *name,
_ => false,
},
BreakPoint::AtFunctionCall { name, args, .. } => match node {
ASTNode::Expr(Expr::FnCall(x, _))
| ASTNode::Stmt(Stmt::FnCall(x, _))
| ASTNode::Stmt(Stmt::Expr(Expr::FnCall(x, _))) => {
ASTNode::Expr(Expr::FnCall(x, ..))
| ASTNode::Stmt(Stmt::FnCall(x, ..))
| ASTNode::Stmt(Stmt::Expr(Expr::FnCall(x, ..))) => {
x.args.len() == *args && x.name == *name
}
_ => false,
},
#[cfg(not(feature = "no_object"))]
BreakPoint::AtProperty { name, .. } => match node {
ASTNode::Expr(Expr::Property(x, _)) => x.2 == *name,
ASTNode::Expr(Expr::Property(x, ..)) => x.2 == *name,
_ => false,
},
})
.map(|(i, _)| i)
.map(|(i, ..)| i)
}
/// Get a slice of all [`BreakPoint`]'s.
#[inline(always)]
@@ -525,7 +525,7 @@ impl Engine {
level,
};
if let Some((_, ref on_debugger)) = self.debugger {
if let Some((.., ref on_debugger)) = self.debugger {
let command = on_debugger(&mut context, event, node, source, node.position())?;
match command {
@@ -548,9 +548,9 @@ impl Engine {
DebuggerCommand::FunctionExit => {
// Bump a level if it is a function call
let level = match node {
ASTNode::Expr(Expr::FnCall(_, _))
| ASTNode::Stmt(Stmt::FnCall(_, _))
| ASTNode::Stmt(Stmt::Expr(Expr::FnCall(_, _))) => context.call_level() + 1,
ASTNode::Expr(Expr::FnCall(..))
| ASTNode::Stmt(Stmt::FnCall(..))
| ASTNode::Stmt(Stmt::Expr(Expr::FnCall(..))) => context.call_level() + 1,
_ => context.call_level(),
};
global.debugger.status = DebuggerStatus::FunctionExit(level);