File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ use std:: convert:: TryFrom ;
12use std:: error:: Error ;
23use std:: fmt:: { self , Display } ;
34use std:: str:: FromStr ;
@@ -86,3 +87,10 @@ impl FromStr for Method {
8687 }
8788 }
8889}
90+
91+ impl < ' a > TryFrom < & ' a str > for Method {
92+ type Error = ParseError ;
93+ fn try_from ( s : & ' a str ) -> Result < Self , Self :: Error > {
94+ s. parse ( )
95+ }
96+ }
Original file line number Diff line number Diff line change 11use async_std:: io:: { self , BufRead , Read } ;
22
33use std:: borrow:: Borrow ;
4+ use std:: convert:: TryInto ;
45use std:: fmt:: { self , Debug } ;
56use std:: pin:: Pin ;
67use std:: task:: { Context , Poll } ;
@@ -35,12 +36,16 @@ pin_project_lite::pin_project! {
3536
3637impl Request {
3738 /// Create a new request.
38- pub fn new (
39- method : impl Into < Method > ,
39+ pub fn new < M > (
40+ method : M ,
4041 url : Url ,
41- ) -> Result < Self , Box < dyn std:: error:: Error + Send + Sync + ' static > > {
42+ ) -> Result < Self , Box < dyn std:: error:: Error + Send + Sync + ' static > >
43+ where
44+ M : TryInto < Method > ,
45+ <M as TryInto < Method > >:: Error : Sync + Send + std:: error:: Error + ' static ,
46+ {
4247 Ok ( Self {
43- method : method. into ( ) ,
48+ method : method. try_into ( ) ? ,
4449 url,
4550 headers : Headers :: new ( ) ,
4651 body_reader : Box :: new ( io:: empty ( ) ) ,
You can’t perform that action at this time.
0 commit comments