#Axum docs show a tuple struct (???) being used as a function parameter's name

4 messages · Page 1 of 1 (latest)

opaque relic
#

Can someone breakdown what's going on here? I'm extremely confused.

async fn create_user(extract::Json(payload): extract::Json<CreateUser>) {
    // payload is a `CreateUser`
}```
https://docs.rs/axum/latest/axum/struct.Json.html

This is a struct tuple of a single `T` right? How is it being used as the name of a parameter?
gleaming sinew
#

Function arguments can be any irrefutable pattern, just like in let statements. You can do things like

fn a(&n: &i32)
fn b((y, x): (u8, u8))
fn c(SomeStruct { field: x }: SomeStruct)
opaque relic