From 3203871d6b608b9dbb75ca39143424582e5e578c Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 26 Mar 2022 00:32:52 +0000 Subject: [PATCH] Introduce InvalidAbbrevPresentationLayout error type Signed-off-by: Ian Jackson --- src/ui.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/ui.rs b/src/ui.rs index 38be33c1..855099cd 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -74,14 +74,18 @@ impl Default for PresentationLayout { #[derive(Debug)] pub struct AbbrevPresentationLayout(pub PresentationLayout); +#[derive(Error,Debug,Clone,Copy)] +#[error("Invalid presentation layout character")] +pub struct InvalidAbbrevPresentationLayout; + impl FromStr for AbbrevPresentationLayout { - type Err = (); + type Err = InvalidAbbrevPresentationLayout; #[throws(Self::Err)] fn from_str(s: &str) -> Self { AbbrevPresentationLayout(match s { "p" => PL::Portrait, "l" => PL::Landscape, - _ => throw!(()) + _ => throw!(InvalidAbbrevPresentationLayout) }) } } -- 2.30.2