Mercurial > public > mercurial-scm > hg-stable
diff rust/hg-core/src/matchers.rs @ 50884:f50e71fdfcb4
rust: improve the type on DirsMultiset::from_manifest
It could only return an HgPathError, but we didn't express this in the
type, so we needed some unreachable!()s. Now that is expressed in the
type.
author | Spencer Baugh <sbaugh@janestreet.com> |
---|---|
date | Tue, 08 Aug 2023 11:50:26 -0400 |
parents | e037af7de2ce |
children | 090658724abf |
line wrap: on
line diff
--- a/rust/hg-core/src/matchers.rs Wed Aug 02 09:59:49 2023 -0400 +++ b/rust/hg-core/src/matchers.rs Tue Aug 08 11:50:26 2023 -0400 @@ -15,11 +15,10 @@ }, utils::{ files::find_dirs, - hg_path::{HgPath, HgPathBuf}, + hg_path::{HgPath, HgPathBuf, HgPathError}, Escaped, }, - DirsMultiset, DirstateMapError, FastHashMap, IgnorePattern, PatternError, - PatternSyntax, + DirsMultiset, FastHashMap, IgnorePattern, PatternError, PatternSyntax, }; use crate::dirstate::status::IgnoreFnType; @@ -177,7 +176,7 @@ } impl FileMatcher { - pub fn new(files: Vec<HgPathBuf>) -> Result<Self, DirstateMapError> { + pub fn new(files: Vec<HgPathBuf>) -> Result<Self, HgPathError> { let dirs = DirsMultiset::from_manifest(&files)?; Ok(Self { files: HashSet::from_iter(files.into_iter()), @@ -760,20 +759,12 @@ let mut parents = HashSet::new(); parents.extend( - DirsMultiset::from_manifest(&dirs) - .map_err(|e| match e { - DirstateMapError::InvalidPath(e) => e, - _ => unreachable!(), - })? + DirsMultiset::from_manifest(&dirs)? .iter() .map(ToOwned::to_owned), ); parents.extend( - DirsMultiset::from_manifest(&roots) - .map_err(|e| match e { - DirstateMapError::InvalidPath(e) => e, - _ => unreachable!(), - })? + DirsMultiset::from_manifest(&roots)? .iter() .map(ToOwned::to_owned), );