@@ -67,15 +67,6 @@ pub struct GitUrl {
6767 hint : GitUrlParseHint ,
6868}
6969
70- /// Build the printable GitUrl from its components
71- impl fmt:: Display for GitUrl {
72- fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
73- let git_url_str = self . display ( ) ;
74-
75- write ! ( f, "{git_url_str}" , )
76- }
77- }
78-
7970impl GitUrl {
8071 /// scheme name (i.e. `scheme://`)
8172 pub fn scheme ( & self ) -> Option < & str > {
@@ -130,7 +121,7 @@ impl GitUrl {
130121 }
131122
132123 /// This method rebuilds the printable GitUrl from its components.
133- /// `url_compat` results in output that can be parsed by the `url` crate
124+ /// `url_compat` results in output that can be parsed by the [ `url`](https://docs.rs/url/latest/url/) crate
134125 fn build_string ( & self , url_compat : bool ) -> String {
135126 let scheme = if self . print_scheme ( ) || url_compat {
136127 if let Some ( scheme) = self . scheme ( ) {
@@ -176,45 +167,7 @@ impl GitUrl {
176167 let git_url_str = format ! ( "{scheme}{auth_info}{host}{port}{path}" ) ;
177168 git_url_str
178169 }
179- }
180-
181- #[ cfg( feature = "url" ) ]
182- impl TryFrom < & GitUrl > for Url {
183- type Error = url:: ParseError ;
184- fn try_from ( value : & GitUrl ) -> Result < Self , Self :: Error > {
185- // Since we don't fully implement any spec, we'll rely on the url crate
186- Url :: parse ( & value. url_compat_display ( ) )
187- }
188- }
189-
190- #[ cfg( feature = "url" ) ]
191- impl TryFrom < GitUrl > for Url {
192- type Error = url:: ParseError ;
193- fn try_from ( value : GitUrl ) -> Result < Self , Self :: Error > {
194- // Since we don't fully implement any spec, we'll rely on the url crate
195- Url :: parse ( & value. url_compat_display ( ) )
196- }
197- }
198-
199- #[ cfg( feature = "url" ) ]
200- impl TryFrom < & Url > for GitUrl {
201- type Error = GitUrlParseError ;
202- fn try_from ( value : & Url ) -> Result < Self , Self :: Error > {
203- // Since we don't fully implement any spec, we'll rely on the url crate
204- GitUrl :: parse ( value. as_str ( ) )
205- }
206- }
207-
208- #[ cfg( feature = "url" ) ]
209- impl TryFrom < Url > for GitUrl {
210- type Error = GitUrlParseError ;
211- fn try_from ( value : Url ) -> Result < Self , Self :: Error > {
212- // Since we don't fully implement any spec, we'll rely on the url crate
213- GitUrl :: parse ( value. as_str ( ) )
214- }
215- }
216170
217- impl GitUrl {
218171 /// Returns `GitUrl` after removing all user info values
219172 pub fn trim_auth ( & self ) -> GitUrl {
220173 let mut new_giturl = self . clone ( ) ;
@@ -244,7 +197,7 @@ impl GitUrl {
244197 Ok ( git_url)
245198 }
246199
247- /// Internal parse to `GitUrl` without further validation
200+ /// Internal parse to `GitUrl` without validation steps
248201 fn parse_to_git_url ( input : & str ) -> Result < Self , GitUrlParseError > {
249202 let mut git_url_result = GitUrl :: default ( ) ;
250203 // Error if there are null bytes within the url
@@ -414,3 +367,46 @@ impl GitUrl {
414367 Ok ( ( ) )
415368 }
416369}
370+
371+ /// Build the printable GitUrl from its components
372+ impl fmt:: Display for GitUrl {
373+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
374+ let git_url_str = self . display ( ) ;
375+
376+ write ! ( f, "{git_url_str}" , )
377+ }
378+ }
379+
380+ #[ cfg( feature = "url" ) ]
381+ impl TryFrom < & GitUrl > for Url {
382+ type Error = url:: ParseError ;
383+ fn try_from ( value : & GitUrl ) -> Result < Self , Self :: Error > {
384+ // Since we don't fully implement any spec, we'll rely on the url crate
385+ Url :: parse ( & value. url_compat_display ( ) )
386+ }
387+ }
388+
389+ #[ cfg( feature = "url" ) ]
390+ impl TryFrom < GitUrl > for Url {
391+ type Error = url:: ParseError ;
392+ fn try_from ( value : GitUrl ) -> Result < Self , Self :: Error > {
393+ // Since we don't fully implement any spec, we'll rely on the url crate
394+ Url :: parse ( & value. url_compat_display ( ) )
395+ }
396+ }
397+
398+ #[ cfg( feature = "url" ) ]
399+ impl TryFrom < & Url > for GitUrl {
400+ type Error = GitUrlParseError ;
401+ fn try_from ( value : & Url ) -> Result < Self , Self :: Error > {
402+ GitUrl :: parse ( value. as_str ( ) )
403+ }
404+ }
405+
406+ #[ cfg( feature = "url" ) ]
407+ impl TryFrom < Url > for GitUrl {
408+ type Error = GitUrlParseError ;
409+ fn try_from ( value : Url ) -> Result < Self , Self :: Error > {
410+ GitUrl :: parse ( value. as_str ( ) )
411+ }
412+ }
0 commit comments