fn members_with_features_old(
        &self,
        specs: &[PackageIdSpec],
        cli_features: &CliFeatures,
    ) -> Vec<(&Package, CliFeatures)> {
        // Split off any features with the syntax `member-name/feature-name` into a map
        // so that those features can be applied directly to those workspace-members.
        let mut member_specific_features: HashMap<InternedString, BTreeSet<FeatureValue>> =
            HashMap::new();
        // Features for the member in the current directory.
        let mut cwd_features = BTreeSet::new();
        for feature in cli_features.features.iter() {
            match feature {
                FeatureValue::Feature(_) => {
                    cwd_features.insert(feature.clone());
                }
                // This should be enforced by CliFeatures.
                FeatureValue::Dep { .. } => panic!("unexpected dep: syntax {}", feature),
                FeatureValue::DepFeature {
                    dep_name,
                    dep_feature,
                    weak: _,
                } => {
                    // I think weak can be ignored here.
                    // * With `--features member?/feat -p member`, the ? doesn't
                    //   really mean anything (either the member is built or it isn't).
                    // * With `--features nonmember?/feat`, cwd_features will
                    //   handle processing it correctly.
                    let is_member = self.members().any(|member| {
                        // Check if `dep_name` is member of the workspace, but isn't associated with current package.
                        self.current_opt() != Some(member) && member.name() == *dep_name
                    });
                    if is_member && specs.iter().any(|spec| spec.name() == *dep_name) {
                        member_specific_features
                            .entry(*dep_name)
                            .or_default()
                            .insert(FeatureValue::Feature(*dep_feature));
                    } else {
                        cwd_features.insert(feature.clone());
                    }
                }
            }
        }

        let ms: Vec<_> = self
            .members()
            .filter_map(|member| {
                let member_id = member.package_id();
                match self.current_opt() {
                    // The features passed on the command-line only apply to
                    // the "current" package (determined by the cwd).
                    Some(current) if member_id == current.package_id() => {
                        let feats = CliFeatures {
                            features: Rc::new(cwd_features.clone()),
                            all_features: cli_features.all_features,
                            uses_default_features: cli_features.uses_default_features,
                        };
                        Some((member, feats))
                    }
                    _ => {
                        // Ignore members that are not enabled on the command-line.
                        if specs.iter().any(|spec| spec.matches(member_id)) {
                            // -p for a workspace member that is not the "current"
                            // one.
                            //
                            // The odd behavior here is due to backwards
                            // compatibility. `--features` and
                            // `--no-default-features` used to only apply to the
                            // "current" package. As an extension, this allows
                            // member-name/feature-name to set member-specific
                            // features, which should be backwards-compatible.
                            let feats = CliFeatures {
                                features: Rc::new(
                                    member_specific_features
                                        .remove(member.name().as_str())
                                        .unwrap_or_default(),
                                ),
                                uses_default_features: true,
                                all_features: cli_features.all_features,
                            };
                            Some((member, feats))
                        } else {
                            // This member was not requested on the command-line, skip.
                            None
                        }
                    }
                }
            })
            .collect();

        // If any member specific features were not removed while iterating over members
        // some features will be ignored.
        assert!(member_specific_features.is_empty());

        ms
    }
/// This is the "old" behavior for command-line feature selection.
/// See `allows_new_cli_feature_behavior`.
This is the "old" behavior for command-line feature selection.
This is the " old " behavior for command - line feature selection .
fn members_with_features_old(
        &self,
        specs: &[PackageIdSpec],
        cli_features: &CliFeatures,
    ) -> Vec<(&Package, CliFeatures)> {
        // Split off any features with the syntax `member-name/feature-name` into a map
        // so that those features can be applied directly to those workspace-members.
        let mut member_specific_features: HashMap<InternedString, BTreeSet<FeatureValue>> =
            HashMap::new();
        // Features for the member in the current directory.
        let mut cwd_features = BTreeSet::new();
        for feature in cli_features.features.iter() {
            match feature {
                FeatureValue::Feature(_) => {
                    cwd_features.insert(feature.clone());
                }
                // This should be enforced by CliFeatures.
                FeatureValue::Dep { .. } => panic!("unexpected dep: syntax {}", feature),
                FeatureValue::DepFeature {
                    dep_name,
                    dep_feature,
                    weak: _,
                } => {
                    // I think weak can be ignored here.
                    // * With `--features member?/feat -p member`, the ? doesn't
                    //   really mean anything (either the member is built or it isn't).
                    // * With `--features nonmember?/feat`, cwd_features will
                    //   handle processing it correctly.
                    let is_member = self.members().any(|member| {
                        // Check if `dep_name` is member of the workspace, but isn't associated with current package.
                        self.current_opt() != Some(member) && member.name() == *dep_name
                    });
                    if is_member && specs.iter().any(|spec| spec.name() == *dep_name) {
                        member_specific_features
                            .entry(*dep_name)
                            .or_default()
                            .insert(FeatureValue::Feature(*dep_feature));
                    } else {
                        cwd_features.insert(feature.clone());
                    }
                }
            }
        }
        let ms: Vec<_> = self
            .members()
            .filter_map(|member| {
                let member_id = member.package_id();
                match self.current_opt() {
                    // The features passed on the command-line only apply to
                    // the "current" package (determined by the cwd).
                    Some(current) if member_id == current.package_id() => {
                        let feats = CliFeatures {
                            features: Rc::new(cwd_features.clone()),
                            all_features: cli_features.all_features,
                            uses_default_features: cli_features.uses_default_features,
                        };
                        Some((member, feats))
                    }
                    _ => {
                        // Ignore members that are not enabled on the command-line.
                        if specs.iter().any(|spec| spec.matches(member_id)) {
                            // -p for a workspace member that is not the "current"
                            // one.
                            //
                            // The odd behavior here is due to backwards
                            // compatibility. `--features` and
                            // `--no-default-features` used to only apply to the
                            // "current" package. As an extension, this allows
                            // member-name/feature-name to set member-specific
                            // features, which should be backwards-compatible.
                            let feats = CliFeatures {
                                features: Rc::new(
                                    member_specific_features
                                        .remove(member.name().as_str())
                                        .unwrap_or_default(),
                                ),
                                uses_default_features: true,
                                all_features: cli_features.all_features,
                            };
                            Some((member, feats))
                        } else {
                            // This member was not requested on the command-line, skip.
                            None
                        }
                    }
                }
            })
            .collect();
        // If any member specific features were not removed while iterating over members
        // some features will be ignored.
        assert!(member_specific_features.is_empty());
        ms
    }
fn members_with_features_old ( & self , specs : & [ PackageIdSpec ] , cli_features : & CliFeatures , ) -> Vec < ( & Package , CliFeatures ) > { // Split off any features with the syntax `member-name/feature-name` into a map // so that those features can be applied directly to those workspace-members. let mut member_specific_features : HashMap < InternedString , BTreeSet < FeatureValue > > = HashMap :: new ( ) ; // Features for the member in the current directory. let mut cwd_features = BTreeSet :: new ( ) ; for feature in cli_features . features . iter ( ) { match feature { FeatureValue :: Feature ( _ ) => { cwd_features . insert ( feature . clone ( ) ) ; } // This should be enforced by CliFeatures. FeatureValue :: Dep { .. } => panic ! ( " " feature ) , FeatureValue :: DepFeature { dep_name , dep_feature , weak : _ , } => { // I think weak can be ignored here. // * With `--features member?/feat -p member`, the ? doesn't //   really mean anything (either the member is built or it isn't). // * With `--features nonmember?/feat`, cwd_features will //   handle processing it correctly. let is_member = self . members ( ) . any ( | member | { // Check if `dep_name` is member of the workspace, but isn't associated with current package. self . current_opt ( ) != Some ( member ) && member . name ( ) == * dep_name } ) ; if is_member && specs . iter ( ) . any ( | spec | spec . name ( ) == * dep_name ) { member_specific_features . entry ( * dep_name ) . or_default ( ) . insert ( FeatureValue :: Feature ( * dep_feature ) ) ; } else { cwd_features . insert ( feature . clone ( ) ) ; } } } } let ms : Vec < _ > = self . members ( ) . filter_map ( | member | { let member_id = member . package_id ( ) ; match self . current_opt ( ) { // The features passed on the command-line only apply to // the "current" package (determined by the cwd). Some ( current ) if member_id == current . package_id ( ) => { let feats = CliFeatures { features : Rc :: new ( cwd_features . clone ( ) ) , all_features : cli_features . all_features , uses_default_features : cli_features . uses_default_features , } ; Some ( ( member , feats ) ) } _ => { // Ignore members that are not enabled on the command-line. if specs . iter ( ) . any ( | spec | spec . matches ( member_id ) ) { // -p for a workspace member that is not the "current" // one. // // The odd behavior here is due to backwards // compatibility. `--features` and // `--no-default-features` used to only apply to the // "current" package. As an extension, this allows // member-name/feature-name to set member-specific // features, which should be backwards-compatible. let feats = CliFeatures { features : Rc :: new ( member_specific_features . remove ( member . name ( ) . as_str ( ) ) . unwrap_or_default ( ) , ) , uses_default_features : true , all_features : cli_features . all_features , } ; Some ( ( member , feats ) ) } else { // This member was not requested on the command-line, skip. None } } } } ) . collect ( ) ; // If any member specific features were not removed while iterating over members // some features will be ignored. assert ! ( member_specific_features is_empty ( ) ) ; ms }
This is the "old" behavior for command-line feature selection.
This is the " old " behavior for command - line feature selection .
&self
specs
&[PackageIdSpec]
cli_features
&CliFeatures
&self
specs
&[PackageIdSpec]
cli_features
&CliFeatures