From b0d0ee85657533db994ed637228ac42f34849b75 Mon Sep 17 00:00:00 2001 From: Jake McGinty Date: Sat, 6 Nov 2021 18:54:52 +0900 Subject: [PATCH] fix tests --- shared/src/types.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/shared/src/types.rs b/shared/src/types.rs index db33c77..f23766d 100644 --- a/shared/src/types.rs +++ b/shared/src/types.rs @@ -19,16 +19,14 @@ pub struct Interface { } impl FromStr for Interface { - type Err = String; + type Err = InvalidInterfaceName; fn from_str(name: &str) -> Result { if !Hostname::is_valid(name) { - return Err("interface name is not a valid hostname".into()); + Err(InvalidInterfaceName::InvalidChars) + } else { + Ok(Self { name: name.parse()? }) } - let name = name - .parse() - .map_err(|e: InvalidInterfaceName| e.to_string())?; - Ok(Self { name }) } }