From 14023a546ef7be1c0c69b8a1a037a0f981d18f07 Mon Sep 17 00:00:00 2001 From: Gabriel Comte Date: Mon, 30 Mar 2026 09:26:16 +0200 Subject: [PATCH] Replace deprecated Error::description() with thiserror Use thiserror derive for InputError, matching the CurrencyParseError approach. Removes the deprecated description() method and manual Display/Error impls. --- src/cli_input.rs | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/src/cli_input.rs b/src/cli_input.rs index e809457..1a44f9f 100644 --- a/src/cli_input.rs +++ b/src/cli_input.rs @@ -2,8 +2,6 @@ use clap::Parser; use colored::*; use regex::Regex; use si_unit_prefix::SiUnitPrefix; -use std::error::Error; -use std::fmt; use std::num::ParseFloatError; use crate::currencies::Currencies; @@ -35,7 +33,8 @@ pub struct CliInput { pub integer: bool, } -#[derive(Debug)] +#[derive(Debug, thiserror::Error)] +#[error("{details}")] pub struct InputError { details: String, } @@ -48,18 +47,6 @@ impl InputError { } } -impl fmt::Display for InputError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "{}", self.details) - } -} - -impl Error for InputError { - fn description(&self) -> &str { - &self.details - } -} - impl From for InputError { fn from(err: ParseFloatError) -> Self { Self::new(&err.to_string())