From 04fff6070db16feb3432e3d5e6e30c1dbb914c6f Mon Sep 17 00:00:00 2001 From: mario Date: Mon, 4 Jul 2016 16:23:45 +0200 Subject: [PATCH] changed from path().starts_with(PATH/imag-) to path.filename().starts_with(imag-) for simplicity. Also filtered out the command name for displaying --- bin/src/main.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/bin/src/main.rs b/bin/src/main.rs index 3b154a47..32723dc3 100644 --- a/bin/src/main.rs +++ b/bin/src/main.rs @@ -68,17 +68,18 @@ fn get_commands() -> Vec { .into_iter() .filter(|path| { match path { - &Ok(ref path) => path.path().starts_with(format!("{}/imag-", elem)), + &Ok(ref p) => p.file_name() + .to_str() + .map_or(false, |filename| filename.starts_with("imag-")), &Err(_) => false, } }) .filter_map(|x| x.ok()) - .map(|path| { - path.path() - .to_str() - .map(String::from) + .filter_map(|path| { + path.file_name() + .to_str() + .map(String::from) }) - .filter_map(|x| x) .collect() }) })