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, url,
deps.iter() deps.iter()
.map(|(name, dep)| { .map(|(name, dep)| {
dep.to_dependency_split( crate::util::toml::to_dependency(
dep,
name, name,
source, source,
&mut nested_paths, &mut nested_paths,

View File

@ -1694,9 +1694,8 @@ fn inner_dependency_inherit_with<'a>(
}) })
} }
impl<P: ResolveToPath + Clone> schema::TomlDependency<P> { pub(crate) fn to_dependency<P: ResolveToPath + Clone>(
pub(crate) fn to_dependency_split( dep: &schema::TomlDependency<P>,
&self,
name: &str, name: &str,
source_id: SourceId, source_id: SourceId,
nested_paths: &mut Vec<PathBuf>, nested_paths: &mut Vec<PathBuf>,
@ -1706,9 +1705,9 @@ impl<P: ResolveToPath + Clone> schema::TomlDependency<P> {
root: &Path, root: &Path,
features: &Features, features: &Features,
kind: Option<DepKind>, kind: Option<DepKind>,
) -> CargoResult<Dependency> { ) -> CargoResult<Dependency> {
dep_to_dependency( dep_to_dependency(
self, dep,
name, name,
&mut Context { &mut Context {
deps: &mut Vec::new(), deps: &mut Vec::new(),
@ -1722,7 +1721,6 @@ impl<P: ResolveToPath + Clone> schema::TomlDependency<P> {
}, },
kind, kind,
) )
}
} }
fn dep_to_dependency<P: ResolveToPath + Clone>( fn dep_to_dependency<P: ResolveToPath + Clone>(