remove some unwrap_unchecked

This commit is contained in:
Simon Gardling 2025-12-05 20:36:28 -05:00
parent 5480522ddb
commit b08a727fe3
Signed by: titaniumtown
GPG Key ID: 9AB28AC10ECE533D
2 changed files with 4 additions and 11 deletions

View File

@ -489,13 +489,8 @@ impl App for MathApp {
.iter()
.map(|(_, func)| func.get_test_result())
.enumerate()
.filter(|(_, error)| error.is_some())
.map(|(i, error)| {
// use unwrap_unchecked as None Errors are already filtered out
unsafe {
format!("(Function #{}) {}\n", i, error.as_ref().unwrap_unchecked())
}
})
.filter_map(|(i, error)| error.as_ref().map(|x| (i, x)))
.map(|(i, error)| format!("(Function #{}) {}\n", i, error))
.join("");
if !errors_formatted.is_empty() {

View File

@ -1,5 +1,5 @@
use base64::Engine;
use base64::engine::general_purpose;
use base64::Engine;
use egui_plot::{Line, PlotPoint, PlotPoints, Points};
use emath::Pos2;
use itertools::Itertools;
@ -91,9 +91,7 @@ pub fn newtons_method_helper(
.filter(|(prev, curr)| prev.y.is_finite() && curr.y.is_finite())
.filter(|(prev, curr)| prev.y.signum() != curr.y.signum())
.map(|(start, _)| start.x)
.map(|x| newtons_method(f, f_1, x, range, threshold))
.filter(|x| x.is_some())
.map(|x| unsafe { x.unwrap_unchecked() })
.filter_map(|x| newtons_method(f, f_1, x, range, threshold))
.collect()
}