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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
//! Equal joiner for matching on property equality.
use PhantomData;
use Joiner;
/// Marker for same-source joins where each unordered pair is considered once.
;
/// Marker for left/right joins where pair orientation is part of the semantics.
;
/// Creates a joiner that matches when a property is equal on both sides.
///
/// This is the primary joiner for self-joins where you're matching
/// entities from the same collection on a shared property.
///
/// # Example
///
/// ```
/// use solverforge_scoring::stream::joiner::{equal, Joiner};
///
/// #[derive(Clone)]
/// struct Shift {
/// employee_id: Option<usize>,
/// start: i64,
/// }
///
/// // Match shifts with the same employee (self-join)
/// let same_employee = equal(|s: &Shift| s.employee_id);
///
/// let a = Shift {
/// employee_id: Some(5),
/// start: 0,
/// };
/// let b = Shift {
/// employee_id: Some(5),
/// start: 8,
/// };
/// let c = Shift {
/// employee_id: Some(3),
/// start: 16,
/// };
///
/// assert!(same_employee.matches(&a, &b));
/// assert!(!same_employee.matches(&a, &c));
/// ```
/// Creates a joiner that matches when extracted values are equal.
///
/// Use this for cross-joins between different entity types.
///
/// # Example
///
/// ```
/// use solverforge_scoring::stream::joiner::{equal_bi, Joiner};
///
/// #[derive(Clone)]
/// struct Employee {
/// id: usize,
/// department: String,
/// }
/// #[derive(Clone)]
/// struct Task {
/// assigned_to: usize,
/// name: String,
/// }
///
/// // Match employees to their assigned tasks
/// let by_id = equal_bi(|e: &Employee| e.id, |t: &Task| t.assigned_to);
///
/// let emp = Employee {
/// id: 5,
/// department: "Engineering".into(),
/// };
/// let task1 = Task {
/// assigned_to: 5,
/// name: "Review".into(),
/// };
/// let task2 = Task {
/// assigned_to: 3,
/// name: "Test".into(),
/// };
///
/// assert!(by_id.matches(&emp, &task1));
/// assert!(!by_id.matches(&emp, &task2));
/// ```
/// Builds an `EqualJoiner` from raw key extractors (crate-internal adapter
/// for fluent dispatch sites that lift unary keys onto row views).
/// Creates a joiner whose left key inspects the whole joined left row.
///
/// The left closure receives the borrowed left row (recursive `Concat` of
/// `Leaf` views), so the second relationship in a chain can inspect any
/// earlier binding or combine several. The right closure sees only the new
/// right entity. Successive joins keep independent key types: each uniform
/// `.join()` carries its own `K2` domain rather than inheriting the first
/// join's key.
///
/// Row and right-input types stay method-generic (never impl generics), so
/// successive joins keep heterogeneous key types without unifying domains.
/// See `constraint::tests::relational::fluent_chain` for the exercised shapes.
/// A joiner that matches when extracted values are equal.
///
/// Created by the [`equal()`] or [`equal_bi()`] functions.