From 859603d530dc2d9742cf6c3a6047baf4f0df33d1 Mon Sep 17 00:00:00 2001 From: Simon Gardling Date: Mon, 28 Feb 2022 11:39:45 -0500 Subject: [PATCH] fix unnecessary unwrap --- src/function.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/function.rs b/src/function.rs index cc5c51d..d410777 100644 --- a/src/function.rs +++ b/src/function.rs @@ -182,10 +182,10 @@ impl Function { (1..=self.pixel_width) .map(|x| (x as f64 / resolution as f64) + min_x) .map(|x| { - let i = x_data.iter().position(|&r| r == x); + let i_option = x_data.iter().position(|&r| r == x); - if i.is_some() { - back_cache[i.unwrap()] + if let Some(i) = i_option { + back_cache[i] } else { Value::new(x, self.run_func(x)) }