Made conversion into 'SocketType' enum more generic

Now it works for anything that can be converted into String
This commit is contained in:
Jedrzej Stuczynski
2020-01-31 10:10:52 +00:00
parent f13e5ae186
commit b8530c91c1
+3 -9
View File
@@ -39,15 +39,9 @@ pub enum SocketType {
None,
}
impl From<String> 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<S: Into<String>>(val: S) -> Self {
let mut upper = val.into();
upper.make_ascii_uppercase();
match upper.as_ref() {
"TCP" => SocketType::TCP,