From 4fff51e9a15985c04190d8ca2656818ef5ae3889 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?= Date: Sat, 24 Sep 2022 19:00:07 +0200 Subject: [PATCH] error: clippy; gain 128 bytes on Error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maxime “pep” Buquet --- src/error.rs | 12 ++++++------ src/main.rs | 2 ++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/error.rs b/src/error.rs index 203a5f7..c64403b 100644 --- a/src/error.rs +++ b/src/error.rs @@ -25,8 +25,8 @@ pub enum Error { NickAlreadyAssigned(String), NonexistantSession(FullJid), SessionAlreadyExists(FullJid), - XMPPError(TokioXMPPError), - ParserError(ParserError), + Xmpp(Box), + Parser(Box), } impl StdError for Error {} @@ -38,20 +38,20 @@ impl fmt::Display for Error { Error::NickAlreadyAssigned(err) => write!(f, "Nickname already assigned: {}", err), Error::NonexistantSession(err) => write!(f, "Session doesn't exist: {}", err), Error::SessionAlreadyExists(err) => write!(f, "Session already exist: {}", err), - Error::XMPPError(err) => write!(f, "XMPP error: {}", err), - Error::ParserError(err) => write!(f, "Parser error: {}", err), + Error::Xmpp(err) => write!(f, "XMPP error: {}", err), + Error::Parser(err) => write!(f, "Parser error: {}", err), } } } impl From for Error { fn from(err: TokioXMPPError) -> Error { - Error::XMPPError(err) + Error::Xmpp(Box::new(err)) } } impl From for Error { fn from(err: ParserError) -> Error { - Error::ParserError(err) + Error::Parser(Box::new(err)) } } diff --git a/src/main.rs b/src/main.rs index 9787675..5d27ee1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -14,6 +14,8 @@ // along with this program. If not, see . #![feature(let_chains)] +// Maybe change that someday? +#![allow(clippy::result_large_err)] mod component; mod error;