fn query(&self,
             registry: &mut Registry,
             dep: &Dependency) -> CargoResult<Vec<Candidate>> {
        let summaries = try!(registry.query(dep));
        summaries.into_iter().map(Rc::new).map(|summary| {
            let mut replace = None;
            let mut matched_spec = None;
            for &(ref spec, ref dep) in self.replacements.iter() {
                if !spec.matches(summary.package_id()) {
                    continue
                }

                if replace.is_some() {
                    bail!("overlapping replacement specifications found:\n\n  \
                           * {}\n  * {}\n\nboth specifications match: {}",
                          matched_spec.unwrap(), spec, summary.package_id());
                }

                let mut summaries = try!(registry.query(dep)).into_iter();
                let s = try!(summaries.next().chain_error(|| {
                    human(format!("no matching package for override `{}` found\n\
                                   location searched: {}\n\
                                   version required: {}",
                                  spec, dep.source_id(), dep.version_req()))
                }));
                let summaries = summaries.collect::<Vec<_>>();
                if summaries.len() > 0 {
                    let bullets = summaries.iter().map(|s| {
                        format!("  * {}", s.package_id())
                    }).collect::<Vec<_>>();
                    bail!("the replacement specification `{}` matched \
                           multiple packages:\n  * {}\n{}", spec,
                          s.package_id(), bullets.join("\n"));
                }

                // The dependency should be hard-coded to have the same name and
                // an exact version requirement, so both of these assertions
                // should never fail.
                assert_eq!(s.version(), summary.version());
                assert_eq!(s.name(), summary.name());

                replace = Some(Rc::new(s));
                matched_spec = Some(spec.clone());
            }
            Ok(Candidate { summary: summary, replace: replace })
        }).collect()
    }
/// Queries the `registry` to return a list of candidates for `dep`.
///
/// This method is the location where overrides are taken into account. If
/// any candidates are returned which match an override then the override is
/// applied by performing a second query for what the override should
/// return.
Queries the `registry` to return a list of candidates for `dep`.
This method is the location where overrides are taken into account. If
any candidates are returned which match an override then the override is
applied by performing a second query for what the override should
return.
Queries the ` registry ` to return a list of candidates for ` dep ` . This method is the location where overrides are taken into account . If any candidates are returned which match an override then the override is applied by performing a second query for what the override should return .
fn query(&self,
             registry: &mut Registry,
             dep: &Dependency) -> CargoResult<Vec<Candidate>> {
        let summaries = try!(registry.query(dep));
        summaries.into_iter().map(Rc::new).map(|summary| {
            let mut replace = None;
            let mut matched_spec = None;
            for &(ref spec, ref dep) in self.replacements.iter() {
                if !spec.matches(summary.package_id()) {
                    continue
                }
                if replace.is_some() {
                    bail!("overlapping replacement specifications found:\n\n  \
                           * {}\n  * {}\n\nboth specifications match: {}",
                          matched_spec.unwrap(), spec, summary.package_id());
                }
                let mut summaries = try!(registry.query(dep)).into_iter();
                let s = try!(summaries.next().chain_error(|| {
                    human(format!("no matching package for override `{}` found\n\
                                   location searched: {}\n\
                                   version required: {}",
                                  spec, dep.source_id(), dep.version_req()))
                }));
                let summaries = summaries.collect::<Vec<_>>();
                if summaries.len() > 0 {
                    let bullets = summaries.iter().map(|s| {
                        format!("  * {}", s.package_id())
                    }).collect::<Vec<_>>();
                    bail!("the replacement specification `{}` matched \
                           multiple packages:\n  * {}\n{}", spec,
                          s.package_id(), bullets.join("\n"));
                }
                // The dependency should be hard-coded to have the same name and
                // an exact version requirement, so both of these assertions
                // should never fail.
                assert_eq!(s.version(), summary.version());
                assert_eq!(s.name(), summary.name());
                replace = Some(Rc::new(s));
                matched_spec = Some(spec.clone());
            }
            Ok(Candidate { summary: summary, replace: replace })
        }).collect()
    }
fn query ( & self , registry : & mut Registry , dep : & Dependency ) -> CargoResult < Vec < Candidate > > { let summaries = try ! ( registry query ( dep ) ) ; summaries . into_iter ( ) . map ( Rc :: new ) . map ( | summary | { let mut replace = None ; let mut matched_spec = None ; for & ( ref spec , ref dep ) in self . replacements . iter ( ) { if ! spec . matches ( summary . package_id ( ) ) { continue } if replace . is_some ( ) { bail ! ( " \n \n \
 \n \n \n " matched_spec unwrap ( ) spec summary package_id ( ) ) ; } let mut summaries = try ! ( registry query ( dep ) ) . into_iter ( ) ; let s = try ! ( summaries next ( ) chain_error ( { human ( format ( " \n \
 \n \
 " spec dep source_id ( ) dep version_req ( ) ) ) } ) ) ; let summaries = summaries . collect :: < Vec < _ > > ( ) ; if summaries . len ( ) > 0 { let bullets = summaries . iter ( ) . map ( | s | { format ! ( " " s package_id ( ) ) } ) . collect :: < Vec < _ > > ( ) ; bail ! ( " \
 \n \n " spec s package_id ( ) bullets join ( " \n " ) ) ; } // The dependency should be hard-coded to have the same name and // an exact version requirement, so both of these assertions // should never fail. assert_eq ! ( s version ( ) summary version ( ) ) ; assert_eq ! ( s name ( ) summary name ( ) ) ; replace = Some ( Rc :: new ( s ) ) ; matched_spec = Some ( spec . clone ( ) ) ; } Ok ( Candidate { summary : summary , replace : replace } ) } ) . collect ( ) }
Queries the `registry` to return a list of candidates for `dep`.
Queries the ` registry ` to return a list of candidates for ` dep ` .
&self
registry
&mut Registry
dep
&Dependency
&self
registry
&mut Registry
dep
&Dependency