/// Finds the targets for a specifically named target.
Finds the targets for a specifically named target.
Finds the targets for a specifically named target .
fn find_named_targets<'a>(
    packages: &[&'a Package],
    target_name: &str,
    target_desc: &'static str,
    is_expected_kind: fn(&Target) -> bool,
    mode: CompileMode,
) -> CargoResult<Vec<Proposal<'a>>> {
    let filter = |t: &Target| t.name() == target_name && is_expected_kind(t);
    let proposals = filter_targets(packages, filter, true, mode);
    if proposals.is_empty() {
        let targets = packages.iter().flat_map(|pkg| {
            pkg.targets()
                .iter()
                .filter(|target| is_expected_kind(target))
        });
        let suggestion = closest_msg(target_name, targets, |t| t.name());
        failure::bail!(
            "no {} target named `{}`{}",
            target_desc,
            target_name,
            suggestion
        );
    }
    Ok(proposals)
}
fn find_named_targets < ' a > ( packages : & [ & ' a Package ] , target_name : & str , target_desc : & ' static str , is_expected_kind : fn ( & Target ) -> bool , mode : CompileMode , ) -> CargoResult < Vec < Proposal < ' a > > > { let filter = | t : & Target | t . name ( ) == target_name && is_expected_kind ( t ) ; let proposals = filter_targets ( packages , filter , true , mode ) ; if proposals . is_empty ( ) { let targets = packages . iter ( ) . flat_map ( | pkg | { pkg . targets ( ) . iter ( ) . filter ( | target | is_expected_kind ( target ) ) } ) ; let suggestion = closest_msg ( target_name , targets , | t | t . name ( ) ) ; failure :: bail ! ( " " target_desc target_name suggestion ) ; } Ok ( proposals ) }
Finds the targets for a specifically named target.
Finds the targets for a specifically named target .
packages
&[&'a Package]
target_name
&str
target_desc
&'static str
is_expected_kind
fn(&Target) -> bool
mode
CompileMode