Skip to content

Commit

Permalink
docs(source): update doc comments for Source trait
Browse files Browse the repository at this point in the history
  • Loading branch information
weihanglo committed May 19, 2023
1 parent 5b236e2 commit 16f3072
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/cargo/core/source/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ pub trait Source {

/// Attempts to find the packages that match a dependency request.
///
/// Usually you should call [`Source::block_until_ready`] somewhere and
/// wait until package informations become available. Otherwise any query
/// should return a [`Poll::Pending`].
///
/// The `f` argument is expected to get called when any [`Summary`] becomes available.
fn query(
&mut self,
Expand All @@ -70,8 +74,8 @@ pub trait Source {
f: &mut dyn FnMut(Summary),
) -> Poll<CargoResult<()>>;

/// A helper function that collects and returns the result from
/// [`Source::query`] as a list of [`Summary`] items when available.
/// Gathers the result from [`Source::query`] as a list of [`Summary`] items
/// when they become available.
fn query_vec(&mut self, dep: &Dependency, kind: QueryKind) -> Poll<CargoResult<Vec<Summary>>> {
let mut ret = Vec::new();
self.query(dep, kind, &mut |s| ret.push(s)).map_ok(|_| ret)
Expand Down

0 comments on commit 16f3072

Please sign in to comment.