Skip to content

Commit

Permalink
docs(source): consolidate "forwards methods" comment in one place
Browse files Browse the repository at this point in the history
  • Loading branch information
weihanglo committed May 18, 2023
1 parent 5ce31c6 commit 83131fc
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/cargo/core/source/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,28 +184,24 @@ pub enum MaybePackage {
},
}

/// A blanket implementation forwards all methods to [`Source`].
impl<'a, T: Source + ?Sized + 'a> Source for Box<T> {
/// Forwards to `Source::source_id`.
fn source_id(&self) -> SourceId {
(**self).source_id()
}

/// Forwards to `Source::replaced_source_id`.
fn replaced_source_id(&self) -> SourceId {
(**self).replaced_source_id()
}

/// Forwards to `Source::supports_checksums`.
fn supports_checksums(&self) -> bool {
(**self).supports_checksums()
}

/// Forwards to `Source::requires_precise`.
fn requires_precise(&self) -> bool {
(**self).requires_precise()
}

/// Forwards to `Source::query`.
fn query(
&mut self,
dep: &Dependency,
Expand All @@ -223,7 +219,6 @@ impl<'a, T: Source + ?Sized + 'a> Source for Box<T> {
(**self).set_quiet(quiet)
}

/// Forwards to `Source::download`.
fn download(&mut self, id: PackageId) -> CargoResult<MaybePackage> {
(**self).download(id)
}
Expand All @@ -232,12 +227,10 @@ impl<'a, T: Source + ?Sized + 'a> Source for Box<T> {
(**self).finish_download(id, data)
}

/// Forwards to `Source::fingerprint`.
fn fingerprint(&self, pkg: &Package) -> CargoResult<String> {
(**self).fingerprint(pkg)
}

/// Forwards to `Source::verify`.
fn verify(&self, pkg: PackageId) -> CargoResult<()> {
(**self).verify(pkg)
}
Expand All @@ -263,6 +256,7 @@ impl<'a, T: Source + ?Sized + 'a> Source for Box<T> {
}
}

/// A blanket implementation forwards all methods to [`Source`].
impl<'a, T: Source + ?Sized + 'a> Source for &'a mut T {
fn source_id(&self) -> SourceId {
(**self).source_id()
Expand Down

0 comments on commit 83131fc

Please sign in to comment.