From b41cf8a127fb71a91137e2dcfafcfeaaafc9e59d Mon Sep 17 00:00:00 2001 From: Edwin Navarro Date: Sat, 25 Nov 2023 07:06:04 -0800 Subject: [PATCH] Use match for isize Err --- rustworkx-core/src/generators/random_graph.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rustworkx-core/src/generators/random_graph.rs b/rustworkx-core/src/generators/random_graph.rs index 3889ec6a0..b42e10cf7 100644 --- a/rustworkx-core/src/generators/random_graph.rs +++ b/rustworkx-core/src/generators/random_graph.rs @@ -120,7 +120,10 @@ where } } } else { - let num_nodes: isize = num_nodes.try_into().map_err(|_| InvalidInputError).unwrap(); + let num_nodes: isize = match num_nodes.try_into() { + Ok(nodes) => nodes, + Err(_) => return Err(InvalidInputError {}), + }; let lp: f64 = (1.0 - probability).ln(); let between = Uniform::new(0.0, 1.0);