@@ -67,15 +67,6 @@ pub struct GitUrl {
67
67
hint : GitUrlParseHint ,
68
68
}
69
69
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
-
79
70
impl GitUrl {
80
71
/// scheme name (i.e. `scheme://`)
81
72
pub fn scheme ( & self ) -> Option < & str > {
@@ -130,7 +121,7 @@ impl GitUrl {
130
121
}
131
122
132
123
/// 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
134
125
fn build_string ( & self , url_compat : bool ) -> String {
135
126
let scheme = if self . print_scheme ( ) || url_compat {
136
127
if let Some ( scheme) = self . scheme ( ) {
@@ -176,45 +167,7 @@ impl GitUrl {
176
167
let git_url_str = format ! ( "{scheme}{auth_info}{host}{port}{path}" ) ;
177
168
git_url_str
178
169
}
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
- }
216
170
217
- impl GitUrl {
218
171
/// Returns `GitUrl` after removing all user info values
219
172
pub fn trim_auth ( & self ) -> GitUrl {
220
173
let mut new_giturl = self . clone ( ) ;
@@ -244,7 +197,7 @@ impl GitUrl {
244
197
Ok ( git_url)
245
198
}
246
199
247
- /// Internal parse to `GitUrl` without further validation
200
+ /// Internal parse to `GitUrl` without validation steps
248
201
fn parse_to_git_url ( input : & str ) -> Result < Self , GitUrlParseError > {
249
202
let mut git_url_result = GitUrl :: default ( ) ;
250
203
// Error if there are null bytes within the url
@@ -414,3 +367,46 @@ impl GitUrl {
414
367
Ok ( ( ) )
415
368
}
416
369
}
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