Skip to content

Commit

Permalink
Auto merge of #8611 - hbina:rename_into_url, r=ehuss
Browse files Browse the repository at this point in the history
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!
  • Loading branch information
bors committed Aug 19, 2020
2 parents f03698b + 3dbac42 commit 3434334
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/cargo/core/package_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ impl ser::Serialize for PackageId {
"{} {} ({})",
self.inner.name,
self.inner.version,
self.inner.source_id.into_url()
self.inner.source_id.as_url()
))
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/core/resolver/encode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ impl fmt::Display for EncodablePackageId {
write!(f, " {}", s)?;
}
if let Some(s) = &self.source {
write!(f, " ({})", s.into_url())?;
write!(f, " ({})", s.as_url())?;
}
Ok(())
}
Expand Down
10 changes: 5 additions & 5 deletions src/cargo/core/source/source_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ impl SourceId {
}

/// A view of the `SourceId` that can be `Display`ed as a URL.
pub fn into_url(&self) -> SourceIdIntoUrl<'_> {
SourceIdIntoUrl {
pub fn as_url(&self) -> SourceIdAsUrl<'_> {
SourceIdAsUrl {
inner: &*self.inner,
}
}
Expand Down Expand Up @@ -445,7 +445,7 @@ impl ser::Serialize for SourceId {
if self.is_path() {
None::<String>.serialize(s)
} else {
s.collect_str(&self.into_url())
s.collect_str(&self.as_url())
}
}
}
Expand Down Expand Up @@ -545,11 +545,11 @@ impl Hash for SourceId {
}

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

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

0 comments on commit 3434334

Please sign in to comment.