mirror of
https://github.com/tokio-rs/axum.git
synced 2026-09-06 00:00:17 +02:00
Document the fact that debug_handler doesn't work within impl blocks (#1800)
Co-authored-by: David Pedersen <[email protected]>
This commit is contained in:
co-authored by
David Pedersen
parent
43883b8d9b
commit
67befbca52
@@ -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
|
/// # Performance
|
||||||
///
|
///
|
||||||
/// This macro has no effect when compiled with the release profile. (eg. `cargo build --release`)
|
/// This macro has no effect when compiled with the release profile. (eg. `cargo build --release`)
|
||||||
|
|||||||
Reference in New Issue
Block a user