@@ -111,6 +111,19 @@ impl<Tuple: Ord> Relation<Tuple> {
111
111
join:: join_into_relation ( input1, input2, logic)
112
112
}
113
113
114
+ /// Creates a `Relation` by removing all values from `input1` that
115
+ /// share a key with `input2`, and then transforming the reuslting
116
+ /// tuples with the `logic` closure. Like
117
+ /// [`Variable::from_antijoin`] except for use where the inputs
118
+ /// are not varying across iterations.
119
+ pub fn from_antijoin < Key : Ord , Val1 : Ord > (
120
+ input1 : & Relation < ( Key , Val1 ) > ,
121
+ input2 : & Relation < Key > ,
122
+ logic : impl FnMut ( & Key , & Val1 ) -> Tuple ,
123
+ ) -> Self {
124
+ join:: antijoin ( input1, input2, logic)
125
+ }
126
+
114
127
/// Creates a `Relation` from a vector of tuples.
115
128
pub fn from_vec ( mut elements : Vec < Tuple > ) -> Self {
116
129
elements. sort ( ) ;
@@ -264,6 +277,11 @@ impl<Tuple: Ord> Variable<Tuple> {
264
277
265
278
/// Adds tuples from `input1` whose key is not present in `input2`.
266
279
///
280
+ /// Note that `input1` must be a variable: if you have a relation
281
+ /// instead, you can use `Relation::from_antijoin` and then
282
+ /// `Variable::insert`. Note that the result will not vary during
283
+ /// the iteration.
284
+ ///
267
285
/// # Examples
268
286
///
269
287
/// This example starts a collection with the pairs (x, x+1) for x in 0 .. 10. It then
@@ -292,7 +310,7 @@ impl<Tuple: Ord> Variable<Tuple> {
292
310
input2 : & Relation < K > ,
293
311
logic : impl FnMut ( & K , & V ) -> Tuple ,
294
312
) {
295
- join:: antijoin_into ( input1, input2, self , logic)
313
+ self . insert ( join:: antijoin ( input1, input2, logic) )
296
314
}
297
315
298
316
/// Adds tuples that result from mapping `input`.
0 commit comments