From b8530c91c17c28a151f85d75b893e32b086800fb Mon Sep 17 00:00:00 2001 From: Jedrzej Stuczynski Date: Fri, 31 Jan 2020 10:10:52 +0000 Subject: [PATCH] Made conversion into 'SocketType' enum more generic Now it works for anything that can be converted into String --- nym-client/src/client/mod.rs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/nym-client/src/client/mod.rs b/nym-client/src/client/mod.rs index ffcd00f141..d5be2af964 100644 --- a/nym-client/src/client/mod.rs +++ b/nym-client/src/client/mod.rs @@ -39,15 +39,9 @@ pub enum SocketType { None, } -impl From for SocketType { - fn from(v: String) -> Self { - Self::from(v.as_ref()) - } -} - -impl From<&str> for SocketType { - fn from(v: &str) -> Self { - let mut upper = v.to_string(); +impl SocketType { + pub fn from_string>(val: S) -> Self { + let mut upper = val.into(); upper.make_ascii_uppercase(); match upper.as_ref() { "TCP" => SocketType::TCP,