diff --git a/core/http/src/method.rs b/core/http/src/method.rs index cf6129ea..2b273181 100644 --- a/core/http/src/method.rs +++ b/core/http/src/method.rs @@ -316,6 +316,12 @@ pub struct ParseMethodError; impl std::error::Error for ParseMethodError { } +impl From for ParseMethodError { + fn from(infallible: std::convert::Infallible) -> Self { + match infallible {} + } +} + impl fmt::Display for ParseMethodError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str("invalid HTTP method") @@ -331,6 +337,14 @@ impl FromStr for Method { } } +impl TryFrom<&str> for Method { + type Error = ParseMethodError; + + fn try_from(s: &str) -> Result { + Self::try_from(s.as_bytes()) + } +} + impl AsRef for Method { fn as_ref(&self) -> &str { self.as_str()