File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -100,6 +100,16 @@ impl<Tuple: Ord> Relation<Tuple> {
100100 Relation { elements }
101101 }
102102
103+ /// Creates a `Relation` from the elements of the `iterator`.
104+ ///
105+ /// Same as the `from_iter` method from `std::iter::FromIterator` trait.
106+ pub fn from_iter < I > ( iterator : I ) -> Self
107+ where
108+ I : IntoIterator < Item = Tuple >
109+ {
110+ iterator. into_iter ( ) . collect ( )
111+ }
112+
103113 /// Creates a `Relation` using the `leapjoin` logic;
104114 /// see [`Variable::leapjoin`]
105115 pub fn from_leapjoin < ' a , SourceTuple : Ord , Val : Ord + ' a > (
@@ -138,7 +148,7 @@ impl<Tuple: Ord> Relation<Tuple> {
138148 /// Construct a new relation by mapping another one. Equivalent to
139149 /// creating an iterator but perhaps more convenient. Analogous to
140150 /// `Variable::from_map`.
141- pub fn from_map < T2 : Ord > ( & self , input : & Relation < T2 > , logic : impl FnMut ( & T2 ) -> Tuple ) -> Self {
151+ pub fn from_map < T2 : Ord > ( input : & Relation < T2 > , logic : impl FnMut ( & T2 ) -> Tuple ) -> Self {
142152 input. iter ( ) . map ( logic) . collect ( )
143153 }
144154
You can’t perform that action at this time.
0 commit comments