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
76
77
78
79
80
use crateRawString;
use ;
/// Represents a **HOCON substitution expression**.
///
/// In HOCON (Human-Optimized Config Object Notation),
/// substitution expressions allow referencing other configuration values.
/// The syntax looks like:
///
/// ```hocon
/// a = ${b.c}
/// optional = ${?x.y}
/// ```
///
/// This structure is used to represent such expressions in the AST (Abstract Syntax Tree).
///
/// # Fields
/// - [`Substitution::path`]: the path being referenced (e.g. `"b.c"` or `"x.y"`).
/// - [`Substitution::optional`]: indicates whether this is an *optional substitution* (`${?...}`).
///
/// # Behavior
/// - If `optional` is `true`, missing values during resolution will not produce an error.
/// - If `optional` is `false`, a missing reference will trigger a substitution error.
///
/// # Examples
///
/// ```rust
/// use hocon_rs::raw::substitution::Substitution;
/// use hocon_rs::raw::raw_string::RawString;
///
/// let normal = Substitution::new(RawString::path_expression(vec![RawString::unquoted("foo"),RawString::unquoted("bar")]), false);
/// let optional = Substitution::new(RawString::path_expression(vec![RawString::unquoted("x"),RawString::unquoted("y")]), true);
///
/// assert_eq!(format!("{}", normal), "${foo.bar}");
/// assert_eq!(format!("{}", optional), "${?x.y}");
/// ```