1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//! Shared iterators for cross-platform traversal.
//!
//! The `for platform in Platform::ALL { if !platform.supports(kind) { continue }
//! let pv = ctx.paths.with_platform(platform); ... }` pattern appears throughout
//! the codebase. This module centralises it so every call site reads as a
//! one-liner filter-map rather than a three-line hand-rolled guard.
//!
//! # Usage
//!
//! ```no_run
//! # use cmx_core::platform_iter;
//! # use cmx_core::types::ArtifactKind;
//! # use cmx_core::context::AppContext;
//! // Iterate every platform that supports `kind`:
//! // for view in platform_iter::views_for(ctx, platform_iter::all(), kind) { ... }
//! //
//! // Put the active platform first:
//! // for view in platform_iter::views_for(ctx, platform_iter::active_first(active), kind) { ... }
//! ```
use iter;
use crateConfigPaths;
use cratePlatform;
use crateArtifactKind;
/// A platform together with the `ConfigPaths` view scoped to it.
///
/// Callers use `view.paths` wherever a platform-specific `ConfigPaths` is
/// needed, and `view.platform` for display or comparisons.
/// Filter `platforms` to those that support `kind` and map each to a
/// [`PlatformView`] that bundles the platform with its scoped [`ConfigPaths`].
///
/// The base paths (`home_dir`, `config_dir`) are cloned from `base_paths` into
/// each view via [`ConfigPaths::with_platform`]; only the active `platform`
/// field changes.
/// Iterate every platform in [`Platform::ALL`] in canonical order.
/// Iterate `active` first, then every other platform in canonical order.
///
/// Mirrors the pattern in `info/mod.rs`: the active platform is searched first
/// so a locally-installed artifact is found without scanning every tool.