From 6a72e51973ec448f3b3d5c9c3f52daeb70829530 Mon Sep 17 00:00:00 2001 From: Richard Walters Date: Mon, 12 Oct 2020 14:20:25 -0700 Subject: Refactoring: collect path functionally --- src/lib.rs | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 1865b1a..f5257b4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -946,20 +946,11 @@ impl Uri { "" => { }, - mut path_string => { - // TODO: Try out this improvement: - // [15:49] silen_z: path_string.split('/').collect() - loop { - if let Some(path_delimiter) = path_string.find('/') { - path_encoded.push( - path_string[0..path_delimiter].to_string() - ); - path_string = &path_string[path_delimiter+1..]; - } else { - path_encoded.push(path_string.to_string()); - break; - } - } + path_string => { + path_encoded = path_string + .split('/') + .map(String::from) + .collect() } } path_encoded.into_iter().map( -- cgit v1.2.3