What's the purpose of T in Handler? #3024
-
Summary
All in all, it seems like nothing would be lost if (The reason I ask is I'm trying to write a trait with a function that will return a axum version0.7.7 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Feel free to play around with the code. You can try deleting it and see what happens. And honestly, I'd recommend doing just that because I'm not sure how much the following will make sense without you playing with the code. The main reason is that we're creating multiple blanket implementations for the trait, one for The second part of that parameter is usually named |
Beta Was this translation helpful? Give feedback.
Feel free to play around with the code. You can try deleting it and see what happens. And honestly, I'd recommend doing just that because I'm not sure how much the following will make sense without you playing with the code.
The main reason is that we're creating multiple blanket implementations for the trait, one for
F: Fn()
, one forF: Fn(T1)
, one forF: Fn(T1, T2)
, etc. Normally, that wouldn't be possible because rustc would see that as conflicting implementations so we need to convince it it's actually slightly different traits. See this example, it might better show you what I'm trying to get across, the commented out code wouldn't work.The second part of that parameter is usually n…