mirror of https://github.com/rwf2/Rocket.git
Impl 'TryFrom<&str>' for 'Method'.
Also implements 'From<Infallible>' for 'ParseMethodError'.
This commit is contained in:
parent
4c71ed6ee3
commit
ef1cfa0965
|
@ -316,6 +316,12 @@ pub struct ParseMethodError;
|
||||||
|
|
||||||
impl std::error::Error for ParseMethodError { }
|
impl std::error::Error for ParseMethodError { }
|
||||||
|
|
||||||
|
impl From<std::convert::Infallible> for ParseMethodError {
|
||||||
|
fn from(infallible: std::convert::Infallible) -> Self {
|
||||||
|
match infallible {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl fmt::Display for ParseMethodError {
|
impl fmt::Display for ParseMethodError {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
f.write_str("invalid HTTP method")
|
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, Self::Error> {
|
||||||
|
Self::try_from(s.as_bytes())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl AsRef<str> for Method {
|
impl AsRef<str> for Method {
|
||||||
fn as_ref(&self) -> &str {
|
fn as_ref(&self) -> &str {
|
||||||
self.as_str()
|
self.as_str()
|
||||||
|
|
Loading…
Reference in New Issue