cloudflare / cloudflare/workers-rs
[Feature] Add `[must_use]` attribute and implement `IntoFuture` for `D1PreparedStatement`
- Dominant language
- Rust
- Stars
- 3.7k
- Forks
- 429
- Avg merge
- 20h 28m
- Merged PRs (30d)
- 7
Description
### Is there an existing issue for this?
- [x] I have searched the existing issues
### Description
`D1PreparedStatement` is just a statement, which has not been executed actually. However, user could make mistake by writing code like this:
```rust
query!(&self.db, "DELETE FROM users WHERE id = ?", id)?; // correct version: query!(&self.db, "DELETE FROM users WHERE id = ?", id)?.all().await?
```
This code does not work, `D1PreparedStatement` just like a `Future` in Rust. It wouldn't been executed automatically, it must been called explicitly .
I suggest that we could implement `IntoFuture` for `D1PreparedStatement`, so that we can execute a statement by `await` it directly. What's more, `D1PreparedStatement` need to been attributed as `#[must_use]`, to avoid misuse statically.
Contributor guide
Assessment
This issue has not been assessed yet.