mirror of
https://github.com/tokio-rs/axum.git
synced 2025-04-26 13:56:22 +02:00
Document the fact that debug_handler
doesn't work within impl blocks (#1800)
Co-authored-by: David Pedersen <david.pdrsn@gmail.com>
This commit is contained in:
parent
43883b8d9b
commit
67befbca52
1 changed files with 26 additions and 0 deletions
|
@ -540,6 +540,32 @@ pub fn derive_from_request_parts(item: TokenStream) -> TokenStream {
|
|||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// # Limitations
|
||||
///
|
||||
/// This macro does not work for associated functions — functions defined in an `impl` block that
|
||||
/// don't take `self`:
|
||||
///
|
||||
/// ```compile_fail
|
||||
/// use axum::{debug_handler, extract::Path};
|
||||
///
|
||||
/// struct App {}
|
||||
///
|
||||
/// impl App {
|
||||
/// #[debug_handler]
|
||||
/// async fn handler(Path(_): Path<String>) {}
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// This will yield an error similar to this:
|
||||
///
|
||||
/// ```text
|
||||
/// error[E0425]: cannot find function `__axum_macros_check_handler_0_from_request_check` in this scope
|
||||
// --> src/main.rs:xx:xx
|
||||
// |
|
||||
// xx | pub async fn handler(Path(_): Path<String>) {}
|
||||
// | ^^^^ not found in this scope
|
||||
/// ```
|
||||
///
|
||||
/// # Performance
|
||||
///
|
||||
/// This macro has no effect when compiled with the release profile. (eg. `cargo build --release`)
|
||||
|
|
Loading…
Add table
Reference in a new issue