diff options
author | Canop <cano.petrole@gmail.com> | 2019-02-20 11:31:01 +0100 |
---|---|---|
committer | Canop <cano.petrole@gmail.com> | 2019-02-20 11:31:01 +0100 |
commit | e9b7ec376594a0764f52925ee11f78aee3cf829f (patch) | |
tree | 9b13c01d5769a2141056e556626b1d25a93d515b | |
parent | e6cf68553c7b6b52d6c9c0eb5cb54b8fa9936db6 (diff) |
replace trivial regex.replace with string.replace
-rw-r--r-- | src/external.rs | 7 | ||||
-rw-r--r-- | src/file_sizes.rs | 1 |
2 files changed, 3 insertions, 5 deletions
diff --git a/src/external.rs b/src/external.rs index a88b0fe..54eaa5c 100644 --- a/src/external.rs +++ b/src/external.rs @@ -1,7 +1,7 @@ use std::io; use std::path::{Path, PathBuf}; use std::process::Command; -use regex::{Regex, NoExpand}; +use regex::Regex; /// description of a possible launch of an external program /// (might be more complex, and a sequence of things to try, in the future). @@ -54,13 +54,12 @@ impl Launchable { // is prettier on screen. pub fn escape_for_shell(path: &Path) -> String { lazy_static! { - static ref SIMPLE_PATH: Regex = Regex::new(r"^[\w/.]+$").unwrap(); - static ref REPLACER: Regex = Regex::new(r"'").unwrap(); + static ref SIMPLE_PATH: Regex = Regex::new(r"^[\w/.]*$").unwrap(); } let path = path.to_string_lossy(); if SIMPLE_PATH.is_match(&path) { path.to_string() } else { - format!("'{}'", REPLACER.replace_all(&path, NoExpand(r"'\''"))) + format!("'{}'", &path.replace('\'', r"'\''")) } } diff --git a/src/file_sizes.rs b/src/file_sizes.rs index 2b1482f..496ddde 100644 --- a/src/file_sizes.rs +++ b/src/file_sizes.rs @@ -75,7 +75,6 @@ impl Size { } /// format a number of bytes as a string - /// (probably fast enough but not benchmarked) pub fn to_string(self) -> String { let mut v = self.0; let mut i = 0; |