From 367719d4082776f66504ba40bf47a319b2a7d8d9 Mon Sep 17 00:00:00 2001 From: greg Date: Thu, 8 Mar 2018 00:32:19 -0800 Subject: [PATCH] Tighten some code --- src/schala_lang/eval.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/schala_lang/eval.rs b/src/schala_lang/eval.rs index 94c521b..fa940e1 100644 --- a/src/schala_lang/eval.rs +++ b/src/schala_lang/eval.rs @@ -175,14 +175,13 @@ impl<'a> State<'a> { } self.eval_application(*f, evaled_arguments) }, - Index { box indexee, mut indexers } => { + Index { box indexee, indexers } => { let evaled = self.eval_expr(indexee)?; match evaled { Tuple(mut exprs) => { let len = indexers.len(); if len == 1 { - indexers.truncate(1); - let idx = indexers.pop().unwrap(); + let idx = indexers.into_iter().nth(0).unwrap(); match self.eval_expr(idx)? { 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)),