Coder Social home page Coder Social logo

Comments (14)

thomaseizinger avatar thomaseizinger commented on August 19, 2024 1

FWIW, a not unified output would have been more powerful because you can always call into_inner if they end up being the same type.

Not sure if you ever plan on doing 2.0 but that could be a consideration :)

from either.

cuviper avatar cuviper commented on August 19, 2024

Is there a reason you're not using futures::future::Either for that?

from either.

thomaseizinger avatar thomaseizinger commented on August 19, 2024

Is there a reason you're not using futures::future::Either for that?

I guess we could yeah! I'll try and report back.

from either.

thomaseizinger avatar thomaseizinger commented on August 19, 2024

It doesn't work at the moment because project is not exposed publicly. However, I think from the previous responses, people are okay with adding it so I'll submit a PR now.

Edit: PR submitted here: rust-lang/futures-rs#2691

from either.

thomaseizinger avatar thomaseizinger commented on August 19, 2024

Another thing I just discovered is that futures::Either has a - IMO - very weird implementation of Future:

impl<A, B> Future for Either<A, B>
where
    A: Future,
    B: Future<Output = A::Output>,
{
    type Output = A::Output;

    fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
        match self.project() {
            Either::Left(x) => x.poll(cx),
            Either::Right(x) => x.poll(cx),
        }
    }
}

I would have expected that a Either<F1, F2> yields me another Either type but the implementation in futures forces both futures to resolve to the same type.

from either.

thomaseizinger avatar thomaseizinger commented on August 19, 2024

Would you be up for merging an implementation of the futures traits that doesn't try to be clever and simply sets all associated types to Either, i.e. Future::Output, Stream::Item, etc

from either.

cuviper avatar cuviper commented on August 19, 2024

Ah, note that Future is a re-export from core, and #77 already implemented that with a unified Output. I'm not sure why I did that -- probably just because that's how we treat Iterator too.

from either.

thomaseizinger avatar thomaseizinger commented on August 19, 2024

Ah, note that Future is a re-export from core, and #77 already implemented that with a unified Output. I'm not sure why I did that -- probably just because that's how we treat Iterator too.

Dang so that would be a breaking change :(

I guess I'll have to stick with my custom Either type then.

from either.

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.