From 42235c42fb9dcf123482bc6bf2fe53e19b001ea4 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Sat, 27 May 2017 12:22:11 +0100 Subject: [PATCH] hashes: Implement From for String. --- src/hashes.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/hashes.rs b/src/hashes.rs index 3c9a05e..f311788 100644 --- a/src/hashes.rs +++ b/src/hashes.rs @@ -47,9 +47,9 @@ impl FromStr for Algo { } } -impl IntoAttributeValue for Algo { - fn into_attribute_value(self) -> Option { - Some(String::from(match self { +impl From for String { + fn from(algo: Algo) -> String { + String::from(match algo { Algo::Sha_1 => "sha-1", Algo::Sha_256 => "sha-256", Algo::Sha_512 => "sha-512", @@ -57,8 +57,14 @@ impl IntoAttributeValue for Algo { Algo::Sha3_512 => "sha3-512", Algo::Blake2b_256 => "blake2b-256", Algo::Blake2b_512 => "blake2b-512", - Algo::Unknown(text) => return Some(text), - })) + Algo::Unknown(text) => return text, + }) + } +} + +impl IntoAttributeValue for Algo { + fn into_attribute_value(self) -> Option { + Some(String::from(self)) } }