File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -125,6 +125,23 @@ pub use self::service::HandlerService;
125
125
/// )));
126
126
/// # let _: Router = app;
127
127
/// ```
128
+ ///
129
+ /// # About type parameter `T`
130
+ ///
131
+ /// **Generally you shouldn't need to worry about `T`**; when calling methods such as
132
+ /// [`post`](crate::routing::method_routing::post) it will be automatically inferred and this is
133
+ /// the intended way for this parameter to be provided in application code.
134
+ ///
135
+ /// If you are implementing your own methods that accept implementations of `Handler` as
136
+ /// arguments, then the following may be useful:
137
+ ///
138
+ /// The type parameter `T` is a workaround for trait coherence rules, allowing us to
139
+ /// write blanket implementations of `Handler` over many types of handler functions
140
+ /// with different numbers of arguments, without the compiler forbidding us from doing
141
+ /// so because one type `F` can in theory implement both `Fn(A) -> X` and `Fn(A, B) -> Y`.
142
+ /// `T` is a placeholder taking on a representation of the parameters of the handler function,
143
+ /// as well as other similar 'coherence rule workaround' discriminators,
144
+ /// allowing us to select one function signature to use as a `Handler`.
128
145
#[ diagnostic:: on_unimplemented(
129
146
note = "Consider using `#[axum::debug_handler]` to improve the error message"
130
147
) ]
You can’t perform that action at this time.
0 commit comments