From 4314421924c256ab13f5a630aff2596c480f6a66 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Tue, 5 Mar 2019 11:56:59 +0100 Subject: Fix in match_iter error handling --- dhall/src/parser.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'dhall') diff --git a/dhall/src/parser.rs b/dhall/src/parser.rs index 36e1726..6c7c0c5 100644 --- a/dhall/src/parser.rs +++ b/dhall/src/parser.rs @@ -128,7 +128,10 @@ macro_rules! match_iter { // Normal pattern after a variable length one: declare reversed and take from the end (@match $w:expr, $iter:expr, $x:ident $($rest:tt)*) => { match_iter!(@match $w, $iter $($rest)*); - let $x = $iter.next_back().unwrap(); + let $x = match $iter.next_back() { + Some(x) => x, + None => break Err(IterMatchError::NotEnoughItems), + }; }; // Check no elements remain -- cgit v1.2.3