I'm looking into the axum crate and the README example shows something I haven't seen before while using Rust - the parameter name is wrapped in a tuple struct. What does this mean and what feature of Rust allows this and also why do something like this?
async fn create_user(
// this argument tells axum to parse the request body
// as JSON into a `CreateUser` type
Json(payload): Json<CreateUser>, // <<<--- this part here
) -> impl IntoResponse {
...
Alright I get it. Thank you @quinedot for that link - it helped a lot. The description in there that helped me the most with this is:
The point is: when you are using pattern matching:
you describe the overall shape of the valueusing a patternon the left-hand-side of the equality or in the "case arms" of a match expression;
while the right-hand-side of the equality, or the so-called discriminator expression of the match will be the value or expression that you are matching against (or, as it's sometimes called, destructuring).