Skip to content

Commit 5493c9f

Browse files
authored
Avoid removing elements from the beginning of a vec (#69)
1 parent d23611d commit 5493c9f

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

parser/src/python.lalrpop

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,11 @@ ExpressionStatement: ast::Stmt = {
114114
let mut targets = vec![set_context(expression, ast::ExprContext::Store)];
115115
let mut values = suffix;
116116

117-
while values.len() > 1 {
118-
targets.push(set_context(values.remove(0), ast::ExprContext::Store));
119-
}
117+
let value = Box::new(values.pop().unwrap());
120118

121-
let value = Box::new(values.into_iter().next().unwrap());
119+
for target in values {
120+
targets.push(set_context(target, ast::ExprContext::Store));
121+
}
122122

123123
ast::Stmt::Assign(
124124
ast::StmtAssign { targets, value, type_comment: None, range: (location..end_location).into() }

parser/src/python.rs

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)