From e6622f13384405472f969c466aa691c6547839e4 Mon Sep 17 00:00:00 2001 From: Christoph Herzog Date: Thu, 21 Dec 2023 14:49:11 +0100 Subject: [PATCH] chore(wasix): Minor QueryError code cleanup Use Self:: instead of QueryError:: --- lib/wasix/src/runtime/resolver/source.rs | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/lib/wasix/src/runtime/resolver/source.rs b/lib/wasix/src/runtime/resolver/source.rs index 07688148e4e..75d36d8b30b 100644 --- a/lib/wasix/src/runtime/resolver/source.rs +++ b/lib/wasix/src/runtime/resolver/source.rs @@ -54,19 +54,17 @@ pub enum QueryError { impl From for QueryError { fn from(value: anyhow::Error) -> Self { - QueryError::Other(value) + Self::Other(value) } } impl Display for QueryError { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - QueryError::Unsupported => { - f.write_str("This type of package specifier isn't supported") - } - QueryError::NotFound => f.write_str("Not found"), - QueryError::Timeout => f.write_str("Timed out"), - QueryError::NoMatches { archived_versions } => match archived_versions.as_slice() { + Self::Unsupported => f.write_str("This type of package specifier isn't supported"), + Self::NotFound => f.write_str("Not found"), + Self::Timeout => f.write_str("Timed out"), + Self::NoMatches { archived_versions } => match archived_versions.as_slice() { [] => f.write_str( "The package was found, but no published versions matched the constraint", ), @@ -82,7 +80,7 @@ impl Display for QueryError { ) } }, - QueryError::Other(e) => Display::fmt(e, f), + Self::Other(e) => Display::fmt(e, f), } } } @@ -90,11 +88,8 @@ impl Display for QueryError { impl std::error::Error for QueryError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { match self { - QueryError::Other(e) => Some(&**e), - QueryError::Unsupported - | QueryError::NotFound - | QueryError::NoMatches - | QueryError::Timeout { .. } => None, + Self::Other(e) => Some(&**e), + Self::Unsupported | Self::NotFound | Self::NoMatches { .. } | Self::Timeout => None, } } }