Skip to content

Commit ac81140

Browse files
committed
wip: extend dependencymap
1 parent 34da2b9 commit ac81140

File tree

2 files changed

+29
-4
lines changed
  • crates
    • pixi_command_dispatcher/src/command_dispatcher
    • pixi_spec_containers/src

2 files changed

+29
-4
lines changed

crates/pixi_command_dispatcher/src/command_dispatcher/mod.rs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -523,11 +523,26 @@ impl CommandDispatcher {
523523
/// 3. Filters out dependencies that are themselves dev sources (to avoid
524524
/// duplication)
525525
///
526-
/// The result can then be passed to `solve_pixi_environment` to create
527-
/// an environment with all the dependencies but without the dev source
528-
/// packages themselves.
526+
/// The result can then be merged into a `PixiEnvironmentSpec` and passed to
527+
/// `solve_pixi_environment` to create an environment with all the dependencies
528+
/// but without the dev source packages themselves.
529529
///
530-
/// # Example use case
530+
/// # Example
531+
///
532+
/// ```ignore
533+
/// // Expand dev sources
534+
/// let expanded = command_dispatcher.expand_dev_sources(spec).await?;
535+
///
536+
/// // Merge into environment spec
537+
/// let mut env_spec = PixiEnvironmentSpec::default();
538+
/// env_spec.dependencies.extend(expanded.dependencies);
539+
/// env_spec.constraints.extend(expanded.constraints);
540+
///
541+
/// // Solve the environment
542+
/// let solved = command_dispatcher.solve_pixi_environment(env_spec).await?;
543+
/// ```
544+
///
545+
/// # Use case
531546
///
532547
/// You're developing two packages (`pkgA` and `pkgB`) where `pkgA` depends
533548
/// on `pkgB`. Instead of building both packages, you can use

crates/pixi_spec_containers/src/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,16 @@ impl<N: Hash + Eq + Clone, D: Hash + Eq + Clone> Extend<(N, D)> for DependencyMa
4848
}
4949
}
5050

51+
impl<N: Hash + Eq + Clone, D: Hash + Eq + Clone> Extend<DependencyMap<N, D>>
52+
for DependencyMap<N, D>
53+
{
54+
fn extend<T: IntoIterator<Item = DependencyMap<N, D>>>(&mut self, iter: T) {
55+
for other in iter {
56+
Extend::<(N, D)>::extend(self, other.into_specs());
57+
}
58+
}
59+
}
60+
5161
impl<'a, M, N: Hash + Eq + Clone + 'a, D: Hash + Eq + Clone + 'a> From<M> for DependencyMap<N, D>
5262
where
5363
M: IntoIterator<Item = Cow<'a, IndexMap<N, D>>>,

0 commit comments

Comments
 (0)