Mercurial > hg
diff rust/hg-core/src/lib.rs @ 50860: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 | a8531bd9210b |
children | c112cc9effdc |
line wrap: on
line diff
--- a/rust/hg-core/src/lib.rs Wed Aug 02 09:59:49 2023 -0400 +++ b/rust/hg-core/src/lib.rs Tue Aug 08 11:50:26 2023 -0400 @@ -66,6 +66,12 @@ InvalidPath(HgPathError), } +impl From<HgPathError> for DirstateMapError { + fn from(error: HgPathError) -> Self { + Self::InvalidPath(error) + } +} + impl fmt::Display for DirstateMapError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { @@ -83,6 +89,12 @@ Common(errors::HgError), } +impl From<HgPathError> for DirstateError { + fn from(error: HgPathError) -> Self { + Self::Map(DirstateMapError::InvalidPath(error)) + } +} + impl fmt::Display for DirstateError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self {