diff --git a/src/key.rs b/src/key.rs index 12f10793a..0c0bb0a34 100644 --- a/src/key.rs +++ b/src/key.rs @@ -29,44 +29,44 @@ impl From for Key { } } -impl std::convert::TryInto for Key { +impl std::convert::TryFrom for SignedSecretKey { type Error = (); - fn try_into(self) -> Result { - match self { + fn try_from(value: Key) -> Result { + match value { Key::Public(_) => Err(()), Key::Secret(key) => Ok(key), } } } -impl<'a> std::convert::TryInto<&'a SignedSecretKey> for &'a Key { +impl<'a> std::convert::TryFrom<&'a Key> for &'a SignedSecretKey { type Error = (); - fn try_into(self) -> Result<&'a SignedSecretKey, Self::Error> { - match self { + fn try_from(value: &'a Key) -> Result { + match value { Key::Public(_) => Err(()), Key::Secret(key) => Ok(key), } } } -impl std::convert::TryInto for Key { +impl std::convert::TryFrom for SignedPublicKey { type Error = (); - fn try_into(self) -> Result { - match self { + fn try_from(value: Key) -> Result { + match value { Key::Public(key) => Ok(key), Key::Secret(_) => Err(()), } } } -impl<'a> std::convert::TryInto<&'a SignedPublicKey> for &'a Key { +impl<'a> std::convert::TryFrom<&'a Key> for &'a SignedPublicKey { type Error = (); - fn try_into(self) -> Result<&'a SignedPublicKey, Self::Error> { - match self { + fn try_from(value: &'a Key) -> Result { + match value { Key::Public(key) => Ok(key), Key::Secret(_) => Err(()), }