pub fn root_patch(&self) -> CargoResult<HashMap<Url, Vec<Dependency>>> {
        let from_manifest = match self.root_maybe() {
            MaybePackage::Package(p) => p.manifest().patch(),
            MaybePackage::Virtual(vm) => vm.patch(),
        };

        let from_config = self.config_patch()?;
        if from_config.is_empty() {
            return Ok(from_manifest.clone());
        }
        if from_manifest.is_empty() {
            return Ok(from_config);
        }

        // We could just chain from_manifest and from_config,
        // but that's not quite right as it won't deal with overlaps.
        let mut combined = from_config;
        for (url, deps_from_manifest) in from_manifest {
            if let Some(deps_from_config) = combined.get_mut(url) {
                // We want from_config to take precedence for each patched name.
                // NOTE: This is inefficient if the number of patches is large!
                let mut from_manifest_pruned = deps_from_manifest.clone();
                for dep_from_config in &mut *deps_from_config {
                    if let Some(i) = from_manifest_pruned.iter().position(|dep_from_manifest| {
                        // XXX: should this also take into account version numbers?
                        dep_from_config.name_in_toml() == dep_from_manifest.name_in_toml()
                    }) {
                        from_manifest_pruned.swap_remove(i);
                    }
                }
                // Whatever is left does not exist in manifest dependencies.
                deps_from_config.extend(from_manifest_pruned);
            } else {
                combined.insert(url.clone(), deps_from_manifest.clone());
            }
        }
        Ok(combined)
    }
/// Returns the root `[patch]` section of this workspace.
///
/// This may be from a virtual crate or an actual crate.
Returns the root `[patch]` section of this workspace.
This may be from a virtual crate or an actual crate.
Returns the root ` [ patch ] ` section of this workspace . This may be from a virtual crate or an actual crate .
pub fn root_patch(&self) -> CargoResult<HashMap<Url, Vec<Dependency>>> {
        let from_manifest = match self.root_maybe() {
            MaybePackage::Package(p) => p.manifest().patch(),
            MaybePackage::Virtual(vm) => vm.patch(),
        };
        let from_config = self.config_patch()?;
        if from_config.is_empty() {
            return Ok(from_manifest.clone());
        }
        if from_manifest.is_empty() {
            return Ok(from_config);
        }
        // We could just chain from_manifest and from_config,
        // but that's not quite right as it won't deal with overlaps.
        let mut combined = from_config;
        for (url, deps_from_manifest) in from_manifest {
            if let Some(deps_from_config) = combined.get_mut(url) {
                // We want from_config to take precedence for each patched name.
                // NOTE: This is inefficient if the number of patches is large!
                let mut from_manifest_pruned = deps_from_manifest.clone();
                for dep_from_config in &mut *deps_from_config {
                    if let Some(i) = from_manifest_pruned.iter().position(|dep_from_manifest| {
                        // XXX: should this also take into account version numbers?
                        dep_from_config.name_in_toml() == dep_from_manifest.name_in_toml()
                    }) {
                        from_manifest_pruned.swap_remove(i);
                    }
                }
                // Whatever is left does not exist in manifest dependencies.
                deps_from_config.extend(from_manifest_pruned);
            } else {
                combined.insert(url.clone(), deps_from_manifest.clone());
            }
        }
        Ok(combined)
    }
pub fn root_patch ( & self ) -> CargoResult < HashMap < Url , Vec < Dependency > > > { let from_manifest = match self . root_maybe ( ) { MaybePackage :: Package ( p ) => p . manifest ( ) . patch ( ) , MaybePackage :: Virtual ( vm ) => vm . patch ( ) , } ; let from_config = self . config_patch ( ) ? ; if from_config . is_empty ( ) { return Ok ( from_manifest . clone ( ) ) ; } if from_manifest . is_empty ( ) { return Ok ( from_config ) ; } // We could just chain from_manifest and from_config, // but that's not quite right as it won't deal with overlaps. let mut combined = from_config ; for ( url , deps_from_manifest ) in from_manifest { if let Some ( deps_from_config ) = combined . get_mut ( url ) { // We want from_config to take precedence for each patched name. // NOTE: This is inefficient if the number of patches is large! let mut from_manifest_pruned = deps_from_manifest . clone ( ) ; for dep_from_config in & mut * deps_from_config { if let Some ( i ) = from_manifest_pruned . iter ( ) . position ( | dep_from_manifest | { // XXX: should this also take into account version numbers? dep_from_config . name_in_toml ( ) == dep_from_manifest . name_in_toml ( ) } ) { from_manifest_pruned . swap_remove ( i ) ; } } // Whatever is left does not exist in manifest dependencies. deps_from_config . extend ( from_manifest_pruned ) ; } else { combined . insert ( url . clone ( ) , deps_from_manifest . clone ( ) ) ; } } Ok ( combined ) }
Returns the root `[patch]` section of this workspace.
Returns the root ` [ patch ] ` section of this workspace .
&self
&self