Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specialize creating Relations from Vecs #10

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
//! normal Rust program, run to completion, and then the results extracted as
//! vectors again.

#![feature(specialization)]
#![forbid(missing_docs)]

use std::rc::Rc;
Expand Down Expand Up @@ -92,11 +93,17 @@ impl<Tuple: Ord> Relation<Tuple> {
}

impl<Tuple: Ord, I: IntoIterator<Item=Tuple>> From<I> for Relation<Tuple> {
fn from(iterator: I) -> Self {
default fn from(iterator: I) -> Self {
Relation::from_vec(iterator.into_iter().collect())
}
}

impl<Tuple: Ord> From<Vec<Tuple>> for Relation<Tuple> {
fn from(v: Vec<Tuple>) -> Self {
Relation::from_vec(v)
}
}

impl<Tuple: Ord> std::ops::Deref for Relation<Tuple> {
type Target = [Tuple];
fn deref(&self) -> &Self::Target {
Expand Down