Giter Site home page Giter Site logo

Comments (10)

Stebalien avatar Stebalien commented on July 25, 2024

Alternatively, one could name these functions interleave_{left,right} etc. to allow for more control.

from itertools.

bluss avatar bluss commented on July 25, 2024

Interesting idea. Either is certainly Iterator-related, it exists partly because I didn't want to reimplement the two-case iterator many times.

There's some overlap between the crates. itertools::Partition could just have been the Either enum. So for that reason it seems like a good idea. It's also a very small crate to add as a dependency. It has the risk of thrusting the either crate and type into a lot more rusties' hands, I wonder what they will think.

The left, right iterators don't seem necessary, since the .left(), .right() methods return options that are iterable. So that functionality is available already through composition.

The extend line would not actually be possible would it, since String::extend doesn't use any generics or AsRef<str> or so, it needs an iterator of &str.

from itertools.

Stebalien avatar Stebalien commented on July 25, 2024

The extend line would not actually be possible would it, since String::extend doesn't use any generics or AsRef or so, it needs an iterator of &str.

See rust-lang/rust#34143 (whether or not this gets accepted, or even should be accepted, is another issue).

The left, right iterators don't seem necessary, since the .left(), .right() methods return options that are iterable. So that functionality is available already through composition.

I'm not sure I follow here. I'm suggesting a helper function and type equivalent to iterator.map(Either::{Left, Right}). This is mostly to get namable types (i.e., avoid functions in types).

from itertools.

bluss avatar bluss commented on July 25, 2024

It sounds like you mean either Either::Left as a function (that already exists) or the method Either::left composed with .unwrap() (Either::left already exists)?

from itertools.

Stebalien avatar Stebalien commented on July 25, 2024

I mean Either::Left as a function. Basically, first.chain_either(second) would be shorthand for first.left().chain(second.right()).

from itertools.

bluss avatar bluss commented on July 25, 2024

aha. So .left() would be an iterator adaptor equivalent to .map(Either::Left)

from itertools.

Stebalien avatar Stebalien commented on July 25, 2024

...caps (yes).

from itertools.

bluss avatar bluss commented on July 25, 2024

The breaking change part of this is going to be done for 0.5. That's changing out Partition for the Either enum

from itertools.

Centril avatar Centril commented on July 25, 2024

I'm personally partial to / and biased in favor of the frunk crate which is more general in that it provides support for "anonymous coproducts" with arbitrary many variants.

from itertools.

bluss avatar bluss commented on July 25, 2024

@Centril sounds interesting, but frunk will not be a dependency of itertools, so we can't do so much with it.

from itertools.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.