From b266b1465393995b3be51d5ba207d5249560884f Mon Sep 17 00:00:00 2001 From: dull b Date: Tue, 25 Jul 2023 18:06:09 +0000 Subject: [PATCH] Add comment about futures --- crates/db_schema/src/traits.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/crates/db_schema/src/traits.rs b/crates/db_schema/src/traits.rs index 736bceb95..c26ba939a 100644 --- a/crates/db_schema/src/traits.rs +++ b/crates/db_schema/src/traits.rs @@ -29,6 +29,11 @@ pub type Delete = DeleteStatement<::Table, = dsl::Find<::Table, >::IdType>; +// When using `RunQueryDsl::execute`, directly building futures with `Box::pin` and `TryFutureExt::and_then` +// instead of `async` + `await` fixes weird compile errors. +// https://github.com/rust-lang/rust/issues/102211 +// When using `RunQueryDsl::first`, `async` + `await` works, and it must be used otherwise the closure for `and_then` +// will both own `conn` and return a future that references it. #[async_trait] pub trait Crud<'a> where