1- use std:: {
2- borrow:: Cow ,
3- convert:: { Infallible , TryFrom } ,
4- } ;
1+ use std:: { borrow:: Cow , convert:: Infallible } ;
52
63pub use bstr;
74use bstr:: { BStr , BString , ByteSlice } ;
@@ -16,8 +13,6 @@ pub enum Error {
1613 Utf8 ( #[ from] std:: str:: Utf8Error ) ,
1714 #[ error( transparent) ]
1815 Url ( #[ from] url:: ParseError ) ,
19- #[ error( "Protocol {protocol:?} is not supported" ) ]
20- UnsupportedProtocol { protocol : String } ,
2116 #[ error( "urls require the path to the repository" ) ]
2217 MissingResourceLocation ,
2318 #[ error( "file urls require an absolute or relative path to the repository repository" ) ]
@@ -34,10 +29,8 @@ impl From<Infallible> for Error {
3429 }
3530}
3631
37- fn str_to_protocol ( s : & str ) -> Result < Scheme , Error > {
38- Scheme :: try_from ( s) . map_err ( |invalid| Error :: UnsupportedProtocol {
39- protocol : invalid. into ( ) ,
40- } )
32+ fn str_to_protocol ( s : & str ) -> Scheme {
33+ Scheme :: from ( s)
4134}
4235
4336fn guess_protocol ( url : & [ u8 ] ) -> Option < & str > {
@@ -70,7 +63,7 @@ fn has_no_explicit_protocol(url: &[u8]) -> bool {
7063fn to_owned_url ( url : url:: Url ) -> Result < crate :: Url , Error > {
7164 Ok ( crate :: Url {
7265 serialize_alternative_form : false ,
73- scheme : str_to_protocol ( url. scheme ( ) ) ? ,
66+ scheme : str_to_protocol ( url. scheme ( ) ) ,
7467 user : if url. username ( ) . is_empty ( ) {
7568 None
7669 } else {
0 commit comments