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
//! Whether a pack named in a token or a hook `run` is the pack it sits in.
//!
//! Token checks and hook `run` checks both ask this question. It is one function so the two
//! cannot decide it differently.
//!
//! # Responsibilities
//!
//! - [`names_own_pack`] is the one rule for "this pack reference points back at its own pack": no
//! pack named, or the pack's own name. The pack's own name is its `pack.toml` name; a pack set
//! keys each pack by that same name, so a caller at either level passes the manifest name.
//!
//! # Non-responsibilities
//!
//! What follows from a reference to another pack (is it required, loaded, does it ship the item)
//! belongs to the checks over a whole set of packs.
use cratePackName;
/// Whether `named`, the pack a token or hook `run` names, is the pack `own` it sits in: nothing
/// named, or `own` itself.
///
/// # Examples
///
/// ```
/// use agentstacks::types::PackName;
/// use agentstacks::types::tokens::names_own_pack;
///
/// let core = PackName::new("core")?;
/// assert!(names_own_pack(None, &core));
/// assert!(names_own_pack(Some(&core), &core));
/// assert!(!names_own_pack(Some(&PackName::new("sdlc")?), &core));
/// # Ok::<(), Box<dyn std::error::Error>>(())
/// ```