Skip to content

Commit 70e7868

Browse files
committed
refactor(registry): merge called flags into one
1 parent 7bb7b53 commit 70e7868

File tree

1 file changed

+8
-6
lines changed
  • src/cargo/sources/registry

1 file changed

+8
-6
lines changed

src/cargo/sources/registry/mod.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -751,20 +751,24 @@ impl<'cfg> Source for RegistrySource<'cfg> {
751751
req.update_precise(&requested);
752752
}
753753

754+
let mut called = false;
755+
let callback = &mut |s| {
756+
called = true;
757+
f(s);
758+
};
759+
754760
// If this is a locked dependency, then it came from a lock file and in
755761
// theory the registry is known to contain this version. If, however, we
756762
// come back with no summaries, then our registry may need to be
757763
// updated, so we fall back to performing a lazy update.
758764
if kind == QueryKind::Exact && req.is_locked() && !self.ops.is_updated() {
759765
debug!("attempting query without update");
760-
let mut called = false;
761766
ready!(self
762767
.index
763768
.query_inner(dep.package_name(), &req, &mut *self.ops, &mut |s| {
764769
if dep.matches(s.as_summary()) {
765770
// We are looking for a package from a lock file so we do not care about yank
766-
called = true;
767-
f(s);
771+
callback(s)
768772
}
769773
},))?;
770774
if called {
@@ -775,7 +779,6 @@ impl<'cfg> Source for RegistrySource<'cfg> {
775779
Poll::Pending
776780
}
777781
} else {
778-
let mut called = false;
779782
ready!(self
780783
.index
781784
.query_inner(dep.package_name(), &req, &mut *self.ops, &mut |s| {
@@ -789,8 +792,7 @@ impl<'cfg> Source for RegistrySource<'cfg> {
789792
if matched
790793
&& (!s.is_yanked() || self.yanked_whitelist.contains(&s.package_id()))
791794
{
792-
f(s);
793-
called = true;
795+
callback(s);
794796
}
795797
}))?;
796798
if called {

0 commit comments

Comments
 (0)