diff options
author | Narawit Rakket <narawitrakket@hotmail.com> | 2022-08-06 18:18:56 +0700 |
---|---|---|
committer | Abin Simon <abinsimon10@gmail.com> | 2022-08-23 23:05:02 +0530 |
commit | e2d046d60b88c3e2b9f1bbe205a12948b1a7e8f5 (patch) | |
tree | 7da2bc02c50a4f41b7e6730cdb50330a8d99c7ee | |
parent | 06ce88dd4669250b6735385fadd2a64f181f675d (diff) |
refactor: use `map_err` instead of `match`
-rw-r--r-- | src/flags/ignore_globs.rs | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/flags/ignore_globs.rs b/src/flags/ignore_globs.rs index 46c6c78..d9b35d1 100644 --- a/src/flags/ignore_globs.rs +++ b/src/flags/ignore_globs.rs @@ -96,20 +96,16 @@ impl IgnoreGlobs { /// /// This method is mainly a helper to wrap the handling of potential errors. fn create_glob(pattern: &str) -> Result<Glob, Error> { - match Glob::new(pattern) { - Ok(glob) => Ok(glob), - Err(err) => Err(Error::raw(ErrorKind::ValueValidation, err)), - } + Glob::new(pattern).map_err(|err| Error::raw(ErrorKind::ValueValidation, err)) } /// Create a [GlobSet] from a provided [GlobSetBuilder]. /// /// This method is mainly a helper to wrap the handling of potential errors. fn create_glob_set(builder: &GlobSetBuilder) -> Result<GlobSet, Error> { - match builder.build() { - Ok(glob_set) => Ok(glob_set), - Err(err) => Err(Error::raw(ErrorKind::ValueValidation, err)), - } + builder + .build() + .map_err(|err| Error::raw(ErrorKind::ValueValidation, err)) } } |