refactor(toml): Make Dep's to_dependency_split a free function

This commit is contained in:
Ed Page 2023-11-30 10:43:24 -06:00
parent 8ff20c7b3c
commit 89f8f5c77a
2 changed files with 29 additions and 30 deletions

View File

@ -437,7 +437,8 @@ impl<'cfg> Workspace<'cfg> {
url,
deps.iter()
.map(|(name, dep)| {
dep.to_dependency_split(
crate::util::toml::to_dependency(
dep,
name,
source,
&mut nested_paths,

View File

@ -1694,35 +1694,33 @@ fn inner_dependency_inherit_with<'a>(
})
}
impl<P: ResolveToPath + Clone> schema::TomlDependency<P> {
pub(crate) fn to_dependency_split(
&self,
name: &str,
source_id: SourceId,
nested_paths: &mut Vec<PathBuf>,
config: &Config,
warnings: &mut Vec<String>,
platform: Option<Platform>,
root: &Path,
features: &Features,
kind: Option<DepKind>,
) -> CargoResult<Dependency> {
dep_to_dependency(
self,
name,
&mut Context {
deps: &mut Vec::new(),
source_id,
nested_paths,
config,
warnings,
platform,
root,
features,
},
kind,
)
}
pub(crate) fn to_dependency<P: ResolveToPath + Clone>(
dep: &schema::TomlDependency<P>,
name: &str,
source_id: SourceId,
nested_paths: &mut Vec<PathBuf>,
config: &Config,
warnings: &mut Vec<String>,
platform: Option<Platform>,
root: &Path,
features: &Features,
kind: Option<DepKind>,
) -> CargoResult<Dependency> {
dep_to_dependency(
dep,
name,
&mut Context {
deps: &mut Vec::new(),
source_id,
nested_paths,
config,
warnings,
platform,
root,
features,
},
kind,
)
}
fn dep_to_dependency<P: ResolveToPath + Clone>(