From 736cd3343084a871f84573f324ec8182f5842af5 Mon Sep 17 00:00:00 2001 From: Craig Mayhew Date: Wed, 22 May 2024 14:21:41 +0100 Subject: [PATCH] refactor: nth() and format!() now only called in the case of a mersenne prime --- src/pages/cruncher.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/pages/cruncher.rs b/src/pages/cruncher.rs index 571911e..631fad1 100644 --- a/src/pages/cruncher.rs +++ b/src/pages/cruncher.rs @@ -619,12 +619,15 @@ fn html_egyptian(slug: &str, max_len_egyptian: usize) -> Node { fn html_mersenne_prime(str_num: &str) -> Node { let n = mersenne::nth_mersenne_prime(str_num) as usize; - let nth = format!("It is the {} ", nth(n)); + let n_th: String; span![ match n { 0 => "It is not a ", - _ => &nth, + _ => { + n_th = format!("It is the {} ", nth(n)); + &n_th + } }, a![ "mersenne prime",