pub fn dep_targets(&self, unit: &Unit<'a>) -> Vec<Unit<'a>> {
        if unit.profile.run_custom_build {
            return self.dep_run_custom_build(unit)
        } else if unit.profile.doc {
            return self.doc_deps(unit);
        }

        let id = unit.pkg.package_id();
        let deps = self.resolve.deps(id).into_iter().flat_map(|a| a);
        let mut ret = deps.map(|id| self.get_package(id)).filter(|dep| {
            unit.pkg.dependencies().iter().filter(|d| {
                d.name() == dep.name()
            }).any(|d| {
                // If this target is a build command, then we only want build
                // dependencies, otherwise we want everything *other than* build
                // dependencies.
                if unit.target.is_custom_build() != d.is_build() {
                    return false
                }

                // If this dependency is *not* a transitive dependency, then it
                // only applies to test/example targets
                if !d.is_transitive() && !unit.target.is_test() &&
                   !unit.target.is_example() && !unit.profile.test {
                    return false
                }

                // If this dependency is only available for certain platforms,
                // make sure we're only enabling it for that platform.
                if !self.dep_platform_activated(d, unit.kind) {
                    return false
                }

                // If the dependency is optional, then we're only activating it
                // if the corresponding feature was activated
                if d.is_optional() {
                    match self.resolve.features(id) {
                        Some(f) if f.contains(d.name()) => {}
                        _ => return false,
                    }
                }

                // If we've gotten past all that, then this dependency is
                // actually used!
                true
            })
        }).filter_map(|pkg| {
            pkg.targets().iter().find(|t| t.is_lib()).map(|t| {
                Unit {
                    pkg: pkg,
                    target: t,
                    profile: self.lib_profile(id),
                    kind: unit.kind.for_target(t),
                }
            })
        }).collect::<Vec<_>>();

        // If this target is a build script, then what we've collected so far is
        // all we need. If this isn't a build script, then it depends on the
        // build script if there is one.
        if unit.target.is_custom_build() {
            return ret
        }
        ret.extend(self.dep_build_script(unit));

        // If this target is a binary, test, example, etc, then it depends on
        // the library of the same package. The call to `resolve.deps` above
        // didn't include `pkg` in the return values, so we need to special case
        // it here and see if we need to push `(pkg, pkg_lib_target)`.
        if unit.target.is_lib() {
            return ret
        }
        ret.extend(self.maybe_lib(unit));

        // Integration tests/benchmarks require binaries to be built
        if unit.profile.test &&
           (unit.target.is_test() || unit.target.is_bench()) {
            ret.extend(unit.pkg.targets().iter().filter(|t| t.is_bin()).map(|t| {
                Unit {
                    pkg: unit.pkg,
                    target: t,
                    profile: self.lib_profile(id),
                    kind: unit.kind.for_target(t),
                }
            }));
        }
        ret
    }
/// For a package, return all targets which are registered as dependencies
/// for that package.
For a package, return all targets which are registered as dependencies
for that package.
For a package return all targets which are registered as dependencies for that package .
pub fn dep_targets(&self, unit: &Unit<'a>) -> Vec<Unit<'a>> {
        if unit.profile.run_custom_build {
            return self.dep_run_custom_build(unit)
        } else if unit.profile.doc {
            return self.doc_deps(unit);
        }
        let id = unit.pkg.package_id();
        let deps = self.resolve.deps(id).into_iter().flat_map(|a| a);
        let mut ret = deps.map(|id| self.get_package(id)).filter(|dep| {
            unit.pkg.dependencies().iter().filter(|d| {
                d.name() == dep.name()
            }).any(|d| {
                // If this target is a build command, then we only want build
                // dependencies, otherwise we want everything *other than* build
                // dependencies.
                if unit.target.is_custom_build() != d.is_build() {
                    return false
                }
                // If this dependency is *not* a transitive dependency, then it
                // only applies to test/example targets
                if !d.is_transitive() && !unit.target.is_test() &&
                   !unit.target.is_example() && !unit.profile.test {
                    return false
                }
                // If this dependency is only available for certain platforms,
                // make sure we're only enabling it for that platform.
                if !self.dep_platform_activated(d, unit.kind) {
                    return false
                }
                // If the dependency is optional, then we're only activating it
                // if the corresponding feature was activated
                if d.is_optional() {
                    match self.resolve.features(id) {
                        Some(f) if f.contains(d.name()) => {}
                        _ => return false,
                    }
                }
                // If we've gotten past all that, then this dependency is
                // actually used!
                true
            })
        }).filter_map(|pkg| {
            pkg.targets().iter().find(|t| t.is_lib()).map(|t| {
                Unit {
                    pkg: pkg,
                    target: t,
                    profile: self.lib_profile(id),
                    kind: unit.kind.for_target(t),
                }
            })
        }).collect::<Vec<_>>();
        // If this target is a build script, then what we've collected so far is
        // all we need. If this isn't a build script, then it depends on the
        // build script if there is one.
        if unit.target.is_custom_build() {
            return ret
        }
        ret.extend(self.dep_build_script(unit));
        // If this target is a binary, test, example, etc, then it depends on
        // the library of the same package. The call to `resolve.deps` above
        // didn't include `pkg` in the return values, so we need to special case
        // it here and see if we need to push `(pkg, pkg_lib_target)`.
        if unit.target.is_lib() {
            return ret
        }
        ret.extend(self.maybe_lib(unit));
        // Integration tests/benchmarks require binaries to be built
        if unit.profile.test &&
           (unit.target.is_test() || unit.target.is_bench()) {
            ret.extend(unit.pkg.targets().iter().filter(|t| t.is_bin()).map(|t| {
                Unit {
                    pkg: unit.pkg,
                    target: t,
                    profile: self.lib_profile(id),
                    kind: unit.kind.for_target(t),
                }
            }));
        }
        ret
    }
pub fn dep_targets ( & self , unit : & Unit < ' a > ) -> Vec < Unit < ' a > > { if unit . profile . run_custom_build { return self . dep_run_custom_build ( unit ) } else if unit . profile . doc { return self . doc_deps ( unit ) ; } let id = unit . pkg . package_id ( ) ; let deps = self . resolve . deps ( id ) . into_iter ( ) . flat_map ( | a | a ) ; let mut ret = deps . map ( | id | self . get_package ( id ) ) . filter ( | dep | { unit . pkg . dependencies ( ) . iter ( ) . filter ( | d | { d . name ( ) == dep . name ( ) } ) . any ( | d | { // If this target is a build command, then we only want build // dependencies, otherwise we want everything *other than* build // dependencies. if unit . target . is_custom_build ( ) != d . is_build ( ) { return false } // If this dependency is *not* a transitive dependency, then it // only applies to test/example targets if ! d . is_transitive ( ) && ! unit . target . is_test ( ) && ! unit . target . is_example ( ) && ! unit . profile . test { return false } // If this dependency is only available for certain platforms, // make sure we're only enabling it for that platform. if ! self . dep_platform_activated ( d , unit . kind ) { return false } // If the dependency is optional, then we're only activating it // if the corresponding feature was activated if d . is_optional ( ) { match self . resolve . features ( id ) { Some ( f ) if f . contains ( d . name ( ) ) => { } _ => return false , } } // If we've gotten past all that, then this dependency is // actually used! true } ) } ) . filter_map ( | pkg | { pkg . targets ( ) . iter ( ) . find ( | t | t . is_lib ( ) ) . map ( | t | { Unit { pkg : pkg , target : t , profile : self . lib_profile ( id ) , kind : unit . kind . for_target ( t ) , } } ) } ) . collect :: < Vec < _ > > ( ) ; // If this target is a build script, then what we've collected so far is // all we need. If this isn't a build script, then it depends on the // build script if there is one. if unit . target . is_custom_build ( ) { return ret } ret . extend ( self . dep_build_script ( unit ) ) ; // If this target is a binary, test, example, etc, then it depends on // the library of the same package. The call to `resolve.deps` above // didn't include `pkg` in the return values, so we need to special case // it here and see if we need to push `(pkg, pkg_lib_target)`. if unit . target . is_lib ( ) { return ret } ret . extend ( self . maybe_lib ( unit ) ) ; // Integration tests/benchmarks require binaries to be built if unit . profile . test && ( unit . target . is_test ( ) || unit . target . is_bench ( ) ) { ret . extend ( unit . pkg . targets ( ) . iter ( ) . filter ( | t | t . is_bin ( ) ) . map ( | t | { Unit { pkg : unit . pkg , target : t , profile : self . lib_profile ( id ) , kind : unit . kind . for_target ( t ) , } } ) ) ; } ret }
For a package, return all targets which are registered as dependencies
for that package.
For a package return all targets which are registered as dependencies for that package .
&self
unit
&Unit<'a>
&self
unit
&Unit<'a>