From c90d2714ffa6aa4d0ffe49399aa3df9135b31a6a Mon Sep 17 00:00:00 2001 From: k-jun Date: Wed, 16 Feb 2022 14:13:39 +0900 Subject: [PATCH] docs(macros): remove sentences banning usage of `as _` (#1619) * docs(macros): remove sentents banning `as _` * fix(macros): comment * Update src/macros.rs * Update src/macros.rs Co-authored-by: keijun-kumagai Co-authored-by: Austin Bonander --- src/macros.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/macros.rs b/src/macros.rs index d05c7bb1e0..c5b66b4ab9 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -147,10 +147,9 @@ /// sqlx::query!("select $1::int4 as id", my_int as MyInt4) /// ``` /// -/// In Rust 1.45 we can eliminate this redundancy by allowing casts using `as _` or type ascription -/// syntax, i.e. `my_int: _` (which is unstable but can be stripped), but this requires modifying -/// the expression which is not possible as the macros are currently implemented. Casts to `_` are -/// forbidden for now as they produce rather nasty type errors. +/// Using `expr as _` or `expr : _` simply signals to the macro to not type-check that bind expression, +/// and then that syntax is stripped from the expression so as to not trigger type errors +/// (or an unstable syntax feature in the case of the latter, which is called type ascription). /// /// ## Type Overrides: Output Columns /// Type overrides are also available for output columns, utilizing the SQL standard's support