Giter Club home page Giter Club logo

Comments (12)

reem avatar reem commented on May 17, 2024

This is a serious problem. We have a lot of existing code that relies on fn's being Cloneable.

from iron.

zzmp avatar zzmp commented on May 17, 2024

Unless you want to pair on rust-lang/rust, I'm not sure we have a recourse.

from iron.

zzmp avatar zzmp commented on May 17, 2024

huon mentioned that the recent break was probably due to this: rust-lang/rust#15191

from iron.

reem avatar reem commented on May 17, 2024

This seems outside of our ability to fix.

I'm going to create a FromFn struct, which would be usable like so:
server.chain.link(FromFn::new(hello_world_fn))

from iron.

reem avatar reem commented on May 17, 2024

Putting it in iron::middleware::FromFn

from iron.

zzmp avatar zzmp commented on May 17, 2024

I don't think we should do this. It still involves changing our code at every point where a bare function was used, so the overhead is the same as just impl'ing a function as fn enter in a middleware struct, but it introduces a lot of technical debt (and what might be considered code bloat). I commented on this strategy when I opened this issue.

Can you come back to discuss this?

from iron.

cburgdorf avatar cburgdorf commented on May 17, 2024

I noticed you handle this issue like this:

fe36c2d

Do you have any insight in how this will be handled upstream? I mean, is it intended that fn is no longer clonable or is this a bug that should be resolved soon?

from iron.

reem avatar reem commented on May 17, 2024

We aren't sure. We think it's a bug with trait detection related to some new logic in the compiler for type checking traits.

FromFn is intentionally bare-bones so it can be easily deleted when this gets resolved.

from iron.

zzmp avatar zzmp commented on May 17, 2024

It should be fixed eventually. There's an active issue out on it - rust-lang/rust#14820.

The plan is to fix it with impl<T:Copy> Clone for T { ... } (stated in the above issue).
(I don't really understand why this isn't possible already, but according to the issue it's not.)

from iron.

cburgdorf avatar cburgdorf commented on May 17, 2024

Ah, I see. Thanks for the pointers!

from iron.

reem avatar reem commented on May 17, 2024

@zzmp it's impossible right now because if you have a generic impl for a trait you can't have any other impls for that trait, which is a known issue.

Basically, if you had impl<T: Copy> Clone for T { fn clone(&self) -> T { *self } } then you couldn't impl Clone for any type that wasn't already Copy which is basically the entire point.

This is also why we have impl Middleware for Box<Chain> instead of impl<C: Chain> Middleware for C.

from iron.

cburgdorf avatar cburgdorf commented on May 17, 2024

@reem don't make my head spin ;-)

from iron.

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.