Skip to content

Commit 170489a

Browse files
committed
remove Relation from the trait as much as possible
1 parent 78fdfaf commit 170489a

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

src/join.rs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,6 @@ use super::{Relation, Variable};
44
use std::cell::Ref;
55
use std::ops::Deref;
66

7-
pub(crate) trait JoinInput<'me, Tuple: Ord>: Copy {
8-
type RecentTuples: Deref<Target = Relation<Tuple>>;
9-
type StableTuples: Deref<Target = Vec<Relation<Tuple>>>;
10-
11-
fn recent(self) -> Self::RecentTuples;
12-
fn stable(self) -> Self::StableTuples;
13-
}
14-
15-
impl<'me, Tuple: Ord> JoinInput<'me, Tuple> for &'me Variable<Tuple> {
16-
type RecentTuples = Ref<'me, Relation<Tuple>>;
17-
type StableTuples = Ref<'me, Vec<Relation<Tuple>>>;
18-
19-
fn recent(self) -> Self::RecentTuples {
20-
self.recent.borrow()
21-
}
22-
23-
fn stable(self) -> Self::StableTuples {
24-
self.stable.borrow()
25-
}
26-
}
27-
287
pub(crate) fn join_into<'me, Key: Ord, Val1: Ord, Val2: Ord, Result: Ord>(
298
input1: impl JoinInput<'me, (Key, Val1)>,
309
input2: impl JoinInput<'me, (Key, Val2)>,
@@ -136,3 +115,24 @@ pub(crate) fn gallop<T>(mut slice: &[T], mut cmp: impl FnMut(&T) -> bool) -> &[T
136115

137116
slice
138117
}
118+
119+
pub(crate) trait JoinInput<'me, Tuple: Ord>: Copy {
120+
type RecentTuples: Deref<Target = [Tuple]>;
121+
type StableTuples: Deref<Target = [Relation<Tuple>]>;
122+
123+
fn recent(self) -> Self::RecentTuples;
124+
fn stable(self) -> Self::StableTuples;
125+
}
126+
127+
impl<'me, Tuple: Ord> JoinInput<'me, Tuple> for &'me Variable<Tuple> {
128+
type RecentTuples = Ref<'me, [Tuple]>;
129+
type StableTuples = Ref<'me, [Relation<Tuple>]>;
130+
131+
fn recent(self) -> Self::RecentTuples {
132+
Ref::map(self.recent.borrow(), |r| &r.elements[..])
133+
}
134+
135+
fn stable(self) -> Self::StableTuples {
136+
Ref::map(self.stable.borrow(), |v| &v[..])
137+
}
138+
}

0 commit comments

Comments
 (0)