Tighten some code
This commit is contained in:
parent
76fadf0701
commit
59d621ed75
@ -175,14 +175,13 @@ impl<'a> State<'a> {
|
|||||||
}
|
}
|
||||||
self.eval_application(*f, evaled_arguments)
|
self.eval_application(*f, evaled_arguments)
|
||||||
},
|
},
|
||||||
Index { box indexee, mut indexers } => {
|
Index { box indexee, indexers } => {
|
||||||
let evaled = self.eval_expr(indexee)?;
|
let evaled = self.eval_expr(indexee)?;
|
||||||
match evaled {
|
match evaled {
|
||||||
Tuple(mut exprs) => {
|
Tuple(mut exprs) => {
|
||||||
let len = indexers.len();
|
let len = indexers.len();
|
||||||
if len == 1 {
|
if len == 1 {
|
||||||
indexers.truncate(1);
|
let idx = indexers.into_iter().nth(0).unwrap();
|
||||||
let idx = indexers.pop().unwrap();
|
|
||||||
match self.eval_expr(idx)? {
|
match self.eval_expr(idx)? {
|
||||||
UnsignedInt(n) if (n as usize) < exprs.len() => Ok(exprs.drain(n as usize..).next().unwrap()),
|
UnsignedInt(n) if (n as usize) < exprs.len() => Ok(exprs.drain(n as usize..).next().unwrap()),
|
||||||
UnsignedInt(n) => Err(format!("Index {} out of range", n)),
|
UnsignedInt(n) => Err(format!("Index {} out of range", n)),
|
||||||
|
Loading…
Reference in New Issue
Block a user