Skip to content

Commit 3434334

Browse files
committed
Auto merge of #8611 - hbina:rename_into_url, r=ehuss
Renames SourceId::into_url -> SourceId::as_url While studying the source code, I am surprised to see that `into_url` does not actually consume its caller when a function with such name usually does. Additionally, there is a trait in `cargo::util::IntoUrl` with the same and does exactly what you expect, consumes itself and yields a `CargoResult<Url>`. I hope this is not too nitpicky. Thank you!
2 parents f03698b + 3dbac42 commit 3434334

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/cargo/core/package_id.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ impl ser::Serialize for PackageId {
5858
"{} {} ({})",
5959
self.inner.name,
6060
self.inner.version,
61-
self.inner.source_id.into_url()
61+
self.inner.source_id.as_url()
6262
))
6363
}
6464
}

src/cargo/core/resolver/encode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ impl fmt::Display for EncodablePackageId {
500500
write!(f, " {}", s)?;
501501
}
502502
if let Some(s) = &self.source {
503-
write!(f, " ({})", s.into_url())?;
503+
write!(f, " ({})", s.as_url())?;
504504
}
505505
Ok(())
506506
}

src/cargo/core/source/source_id.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ impl SourceId {
144144
}
145145

146146
/// A view of the `SourceId` that can be `Display`ed as a URL.
147-
pub fn into_url(&self) -> SourceIdIntoUrl<'_> {
148-
SourceIdIntoUrl {
147+
pub fn as_url(&self) -> SourceIdAsUrl<'_> {
148+
SourceIdAsUrl {
149149
inner: &*self.inner,
150150
}
151151
}
@@ -445,7 +445,7 @@ impl ser::Serialize for SourceId {
445445
if self.is_path() {
446446
None::<String>.serialize(s)
447447
} else {
448-
s.collect_str(&self.into_url())
448+
s.collect_str(&self.as_url())
449449
}
450450
}
451451
}
@@ -545,11 +545,11 @@ impl Hash for SourceId {
545545
}
546546

547547
/// A `Display`able view into a `SourceId` that will write it as a url
548-
pub struct SourceIdIntoUrl<'a> {
548+
pub struct SourceIdAsUrl<'a> {
549549
inner: &'a SourceIdInner,
550550
}
551551

552-
impl<'a> fmt::Display for SourceIdIntoUrl<'a> {
552+
impl<'a> fmt::Display for SourceIdAsUrl<'a> {
553553
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
554554
match *self.inner {
555555
SourceIdInner {

0 commit comments

Comments
 (0)