Our great sponsors
-
sqlx
🧰 The Rust SQL Toolkit. An async, pure Rust SQL crate featuring compile-time checked queries without a DSL. Supports PostgreSQL, MySQL, and SQLite. (by launchbadge)
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
This is why, when we were developing our own SQL client library for Rust, we deliberately made it much easier to just do the right thing and use prepared statements:
Glad you're interested in Rust! First, in case you somehow haven't come across a recommendation already, a great way to learn once you're ready is the free Rust book. And about your question, yes, it would prevent my_str from being "destroyed", though you do have to make one small change - you have to borrow my_str explicitly, like this: