Skip to content

Commit 606dc20

Browse files
Replace RelationLeaper with methods on Relation
1 parent fbcc77a commit 606dc20

File tree

3 files changed

+12
-42
lines changed

3 files changed

+12
-42
lines changed

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub use crate::{
3030
filter_anti::FilterAnti,
3131
filter_with::FilterWith,
3232
filters::{passthrough, PrefixFilter, ValueFilter},
33-
Leaper, Leapers, RelationLeaper,
33+
Leaper, Leapers,
3434
},
3535
variable::Variable,
3636
};

src/test.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
use crate::Iteration;
44
use crate::Relation;
5-
use crate::RelationLeaper;
65
use proptest::prelude::*;
76
use proptest::{proptest, proptest_helper};
87

src/treefrog.rs

Lines changed: 11 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -282,44 +282,9 @@ pub(crate) mod filters {
282282
}
283283
}
284284

285-
/// Extension method for relations.
286-
pub trait RelationLeaper<Key: Ord, Val: Ord> {
285+
impl<Key: Ord, Val: Ord> Relation<(Key, Val)> {
287286
/// Extend with `Val` using the elements of the relation.
288-
fn extend_with<'leap, Tuple: Ord, Func: Fn(&Tuple) -> Key>(
289-
&'leap self,
290-
key_func: Func,
291-
) -> extend_with::ExtendWith<'leap, Key, Val, Tuple, Func>
292-
where
293-
Key: 'leap,
294-
Val: 'leap;
295-
/// Extend with `Val` using the complement of the relation.
296-
fn extend_anti<'leap, Tuple: Ord, Func: Fn(&Tuple) -> Key>(
297-
&'leap self,
298-
key_func: Func,
299-
) -> extend_anti::ExtendAnti<'leap, Key, Val, Tuple, Func>
300-
where
301-
Key: 'leap,
302-
Val: 'leap;
303-
/// Extend with any value if tuple is present in relation.
304-
fn filter_with<'leap, Tuple: Ord, Func: Fn(&Tuple) -> (Key, Val)>(
305-
&'leap self,
306-
key_func: Func,
307-
) -> filter_with::FilterWith<'leap, Key, Val, Tuple, Func>
308-
where
309-
Key: 'leap,
310-
Val: 'leap;
311-
/// Extend with any value if tuple is absent from relation.
312-
fn filter_anti<'leap, Tuple: Ord, Func: Fn(&Tuple) -> (Key, Val)>(
313-
&'leap self,
314-
key_func: Func,
315-
) -> filter_anti::FilterAnti<'leap, Key, Val, Tuple, Func>
316-
where
317-
Key: 'leap,
318-
Val: 'leap;
319-
}
320-
321-
impl<Key: Ord, Val: Ord> RelationLeaper<Key, Val> for Relation<(Key, Val)> {
322-
fn extend_with<'leap, Tuple: Ord, Func: Fn(&Tuple) -> Key>(
287+
pub fn extend_with<'leap, Tuple: Ord, Func: Fn(&Tuple) -> Key>(
323288
&'leap self,
324289
key_func: Func,
325290
) -> extend_with::ExtendWith<'leap, Key, Val, Tuple, Func>
@@ -329,7 +294,9 @@ impl<Key: Ord, Val: Ord> RelationLeaper<Key, Val> for Relation<(Key, Val)> {
329294
{
330295
extend_with::ExtendWith::from(self, key_func)
331296
}
332-
fn extend_anti<'leap, Tuple: Ord, Func: Fn(&Tuple) -> Key>(
297+
298+
/// Extend with `Val` using the complement of the relation.
299+
pub fn extend_anti<'leap, Tuple: Ord, Func: Fn(&Tuple) -> Key>(
333300
&'leap self,
334301
key_func: Func,
335302
) -> extend_anti::ExtendAnti<'leap, Key, Val, Tuple, Func>
@@ -339,7 +306,9 @@ impl<Key: Ord, Val: Ord> RelationLeaper<Key, Val> for Relation<(Key, Val)> {
339306
{
340307
extend_anti::ExtendAnti::from(self, key_func)
341308
}
342-
fn filter_with<'leap, Tuple: Ord, Func: Fn(&Tuple) -> (Key, Val)>(
309+
310+
/// Extend with any value if tuple is present in relation.
311+
pub fn filter_with<'leap, Tuple: Ord, Func: Fn(&Tuple) -> (Key, Val)>(
343312
&'leap self,
344313
key_func: Func,
345314
) -> filter_with::FilterWith<'leap, Key, Val, Tuple, Func>
@@ -349,7 +318,9 @@ impl<Key: Ord, Val: Ord> RelationLeaper<Key, Val> for Relation<(Key, Val)> {
349318
{
350319
filter_with::FilterWith::from(self, key_func)
351320
}
352-
fn filter_anti<'leap, Tuple: Ord, Func: Fn(&Tuple) -> (Key, Val)>(
321+
322+
/// Extend with any value if tuple is absent from relation.
323+
pub fn filter_anti<'leap, Tuple: Ord, Func: Fn(&Tuple) -> (Key, Val)>(
353324
&'leap self,
354325
key_func: Func,
355326
) -> filter_anti::FilterAnti<'leap, Key, Val, Tuple, Func>

0 commit comments

Comments
 (0)