From 1ef10550b1c5d2730194cbc06d7f790b7472dbf8 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Wed, 12 Aug 2015 15:10:03 +0200 Subject: [PATCH] Avoid unwrap calls in handle_navigate_msg. --- components/compositing/constellation.rs | 28 ++++++++++++++++--------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/components/compositing/constellation.rs b/components/compositing/constellation.rs index 50e755eb086..ab5a69b429e 100644 --- a/components/compositing/constellation.rs +++ b/components/compositing/constellation.rs @@ -798,20 +798,28 @@ impl Constellation { let next = match direction { NavigationDirection::Forward => { - if frame.next.is_empty() { - debug!("no next page to navigate to"); - return; + match frame.next.pop() { + None => { + debug!("no next page to navigate to"); + return; + }, + Some(next) => { + frame.prev.push(frame.current); + next + }, } - frame.prev.push(frame.current); - frame.next.pop().unwrap() } NavigationDirection::Back => { - if frame.prev.is_empty() { - debug!("no previous page to navigate to"); - return; + match frame.prev.pop() { + None => { + debug!("no previous page to navigate to"); + return; + }, + Some(prev) => { + frame.next.push(frame.current); + prev + }, } - frame.next.push(frame.current); - frame.prev.pop().unwrap() } }; let prev = frame.current;