Comments (12)
This is a serious problem. We have a lot of existing code that relies on fn's being Cloneable.
from iron.
Unless you want to pair on rust-lang/rust
, I'm not sure we have a recourse.
from iron.
huon mentioned that the recent break was probably due to this: rust-lang/rust#15191
from iron.
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.
Putting it in iron::middleware::FromFn
from iron.
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.
I noticed you handle this issue like this:
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.
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.
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.
Ah, I see. Thanks for the pointers!
from iron.
@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.
@reem don't make my head spin ;-)
from iron.
Related Issues (20)
- replace WriteBody with Into<Body>
- about "too many open file" HOT 4
- URL Parser Unable to Handle IPv6 Addresses HOT 1
- unable to build on nightly (2019-08-01) HOT 1
- Unable to build on nightly HOT 3
- iron::params not parsing query string parameters in 0.6.1 UrlEncodedQuery seems to work with same example. HOT 1
- Typo in documentation link (modifiers) HOT 2
- Keywords and categories in Cargo.toml
- question: Is this repo still in active development? HOT 3
- Unix Domain?
- Is iron Async/Await supported? HOT 1
- Iron::https uses Protocol::http on v0.6.1
- ironframework.io not resolving HOT 3
- ironframework.io serves malicious content HOT 5
- Tests error with latest Rust 1.49
- Is this project still maintained? HOT 2
- Add stale-while-revalidate to CacheDirective
- stop|restart an Iron server
- `req.url` stripping fragments? HOT 2
- Should this crate be used anymore ? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from iron.