tide icon indicating copy to clipboard operation
tide copied to clipboard

src: move State off of Request (WIP)

Open Fishrock123 opened this issue 5 years ago • 3 comments

error[E0119]: conflicting implementations of trait `endpoint::Endpoint<_>`:
  --> src\endpoint.rs:70:1
   |
54 | / impl<State, F, Fut, Res> Endpoint<State> for F
55 | | where
56 | |     State: Send + Sync + 'static,
57 | |     F: Send + Sync + 'static + Fn(Request) -> Fut,
...  |
67 | |     }
68 | | }
   | |_- first implementation here
69 |
70 | / impl<State, F, Fut, Res> Endpoint<State> for F
71 | | where
72 | |     State: Send + Sync + 'static,
73 | |     F: Send + Sync + 'static + Fn(Request, State) -> Fut,
...  |
83 | |     }
84 | | }
   | |_^ conflicting implementation

Not sure I understand this error. F should be a distinct type for both?? Note: the difference is in F and those compiler messages don't show enough lines for that.

Fishrock123 avatar Jul 13 '20 01:07 Fishrock123

I guess the compiler thinks F might implement both Fn(Request) -> Fut and Fn(Request, State) -> Fut. You can make such a type with #![feature(fn_traits, unboxed_closures)] by manually implementing Fn and its supertraits.

tirr-c avatar Jul 13 '20 06:07 tirr-c

Err... this isn't solving the issue that #642 and #644 solve... this is just general ergonomics, imo? Likewise see https://github.com/http-rs/tide/issues/643#issuecomment-657621351

Fishrock123 avatar Jul 13 '20 15:07 Fishrock123

One interesting implication of this PR is that it would've made https://github.com/http-rs/tide/pull/670 easier to implement; no State means no Default either.

yoshuawuyts avatar Jul 31 '20 15:07 yoshuawuyts