@@ -18,7 +18,7 @@ use crate::ops;
18
18
use crate :: sources:: git;
19
19
use crate :: sources:: DirectorySource ;
20
20
use crate :: sources:: { GitSource , PathSource , RegistrySource , CRATES_IO_INDEX } ;
21
- use crate :: util:: { CargoResult , Config , ToUrl } ;
21
+ use crate :: util:: { CargoResult , Config , IntoUrl } ;
22
22
23
23
lazy_static:: lazy_static! {
24
24
static ref SOURCE_ID_CACHE : Mutex <HashSet <& ' static SourceIdInner >> = Mutex :: new( HashSet :: new( ) ) ;
@@ -117,7 +117,7 @@ impl SourceId {
117
117
118
118
match kind {
119
119
"git" => {
120
- let mut url = url. to_url ( ) ?;
120
+ let mut url = url. into_url ( ) ?;
121
121
let mut reference = GitReference :: Branch ( "master" . to_string ( ) ) ;
122
122
for ( k, v) in url. query_pairs ( ) {
123
123
match & k[ ..] {
@@ -135,11 +135,11 @@ impl SourceId {
135
135
Ok ( SourceId :: for_git ( & url, reference) ?. with_precise ( precise) )
136
136
}
137
137
"registry" => {
138
- let url = url. to_url ( ) ?;
138
+ let url = url. into_url ( ) ?;
139
139
Ok ( SourceId :: new ( Kind :: Registry , url) ?. with_precise ( Some ( "locked" . to_string ( ) ) ) )
140
140
}
141
141
"path" => {
142
- let url = url. to_url ( ) ?;
142
+ let url = url. into_url ( ) ?;
143
143
SourceId :: new ( Kind :: Path , url)
144
144
}
145
145
kind => Err ( failure:: format_err!(
@@ -150,8 +150,8 @@ impl SourceId {
150
150
}
151
151
152
152
/// A view of the `SourceId` that can be `Display`ed as a URL.
153
- pub fn to_url ( & self ) -> SourceIdToUrl < ' _ > {
154
- SourceIdToUrl {
153
+ pub fn into_url ( & self ) -> SourceIdIntoUrl < ' _ > {
154
+ SourceIdIntoUrl {
155
155
inner : & * self . inner ,
156
156
}
157
157
}
@@ -160,7 +160,7 @@ impl SourceId {
160
160
///
161
161
/// `path`: an absolute path.
162
162
pub fn for_path ( path : & Path ) -> CargoResult < SourceId > {
163
- let url = path. to_url ( ) ?;
163
+ let url = path. into_url ( ) ?;
164
164
SourceId :: new ( Kind :: Path , url)
165
165
}
166
166
@@ -176,13 +176,13 @@ impl SourceId {
176
176
177
177
/// Creates a SourceId from a local registry path.
178
178
pub fn for_local_registry ( path : & Path ) -> CargoResult < SourceId > {
179
- let url = path. to_url ( ) ?;
179
+ let url = path. into_url ( ) ?;
180
180
SourceId :: new ( Kind :: LocalRegistry , url)
181
181
}
182
182
183
183
/// Creates a `SourceId` from a directory path.
184
184
pub fn for_directory ( path : & Path ) -> CargoResult < SourceId > {
185
- let url = path. to_url ( ) ?;
185
+ let url = path. into_url ( ) ?;
186
186
SourceId :: new ( Kind :: Directory , url)
187
187
}
188
188
@@ -207,7 +207,7 @@ impl SourceId {
207
207
} else {
208
208
CRATES_IO_INDEX
209
209
} ;
210
- let url = url. to_url ( ) ?;
210
+ let url = url. into_url ( ) ?;
211
211
SourceId :: for_registry ( & url)
212
212
} )
213
213
}
@@ -390,7 +390,7 @@ impl ser::Serialize for SourceId {
390
390
if self . is_path ( ) {
391
391
None :: < String > . serialize ( s)
392
392
} else {
393
- s. collect_str ( & self . to_url ( ) )
393
+ s. collect_str ( & self . into_url ( ) )
394
394
}
395
395
}
396
396
}
@@ -504,11 +504,11 @@ impl Hash for SourceId {
504
504
}
505
505
506
506
/// A `Display`able view into a `SourceId` that will write it as a url
507
- pub struct SourceIdToUrl < ' a > {
507
+ pub struct SourceIdIntoUrl < ' a > {
508
508
inner : & ' a SourceIdInner ,
509
509
}
510
510
511
- impl < ' a > fmt:: Display for SourceIdToUrl < ' a > {
511
+ impl < ' a > fmt:: Display for SourceIdIntoUrl < ' a > {
512
512
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
513
513
match * self . inner {
514
514
SourceIdInner {
@@ -579,15 +579,15 @@ impl<'a> fmt::Display for PrettyRef<'a> {
579
579
#[ cfg( test) ]
580
580
mod tests {
581
581
use super :: { GitReference , Kind , SourceId } ;
582
- use crate :: util:: ToUrl ;
582
+ use crate :: util:: IntoUrl ;
583
583
584
584
#[ test]
585
585
fn github_sources_equal ( ) {
586
- let loc = "https://github.com/foo/bar" . to_url ( ) . unwrap ( ) ;
586
+ let loc = "https://github.com/foo/bar" . into_url ( ) . unwrap ( ) ;
587
587
let master = Kind :: Git ( GitReference :: Branch ( "master" . to_string ( ) ) ) ;
588
588
let s1 = SourceId :: new ( master. clone ( ) , loc) . unwrap ( ) ;
589
589
590
- let loc = "git://github.com/foo/bar" . to_url ( ) . unwrap ( ) ;
590
+ let loc = "git://github.com/foo/bar" . into_url ( ) . unwrap ( ) ;
591
591
let s2 = SourceId :: new ( master, loc. clone ( ) ) . unwrap ( ) ;
592
592
593
593
assert_eq ! ( s1, s2) ;
0 commit comments