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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yield a custom struct from OuterJoinIterator #5

Open
apasel422 opened this issue Mar 16, 2015 · 4 comments
Open

Yield a custom struct from OuterJoinIterator #5

apasel422 opened this issue Mar 16, 2015 · 4 comments

Comments

@apasel422
Copy link
Contributor

(A::Key, (Option<A::Val>, Option<A::Val>)) is misleading because the Options cannot both be None. This could be

pub enum OuterJoin<T> {
    Left(T),
    Right(T),
    Both(T, T),
}

with the Item being (A::Key, OuterJoin<A::Val>), but the spatial metaphor is possibly confusing, and Option is more ergonomic.

@erickt
Copy link

erickt commented Apr 15, 2015

I think this makes sense. It fits in well with the relational left inner join and right inner join, which I expect will be eventually implemented.

@Gankra
Copy link
Contributor

Gankra commented Apr 15, 2015

This was discussed offline. I pointed out that it may be more ergonomic to use Options just because Options are Options. Also it makes handing "had left" uniform whereas this design makes "had left" a two-case situation (either Left or Both).

Without usecases it's not clear that either design is better or worse.

@ghost
Copy link

ghost commented Apr 15, 2015

How about adding a to_options method to OuterJoin<T>, giving the best of both worlds.

fn to_options(self) -> (Option<T>, Option<T>);

@Gankra
Copy link
Contributor

Gankra commented Apr 15, 2015

@csherratt My only concern is overhead, but I suppose iterators are supposed to be inlined to annihilation, so that seems like a decent compromise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants