You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would expect that it's possible to create multiple prepared statements for a single connection at once like following:
fncheck<'a>(conn:&'a mut(dynConnection + 'static),) -> (Rc<RefCell<dynStatement + 'a>>,Rc<RefCell<dynStatement + 'a>>,){let a = conn.prepare("SELECT name, id FROM users").unwrap();let b = conn.prepare("SELECT name, id FROM posts").unwrap();(a, b)}
This fails because to create a prepared statement it is required to borrow the connection mutably, which implies that you can only create one prepared statement per connection at one point in time.
This disallows common patterns like a prepared statement cache.
Error message:
error[E0499]: cannot borrow `*conn` as mutable more than once at a time
--> src/main.rs:16:13
|
9 | fn check<'a>(
| -- lifetime `'a` defined here
...
15 | let a = conn.prepare("SELECT name, id FROM users").unwrap();
| ---- first mutable borrow occurs here
16 | let b = conn.prepare("SELECT name, id FROM posts").unwrap();
| ^^^^ second mutable borrow occurs here
17 |
18 | (a, b)
| ------ returning this value requires that `*conn` is borrowed for `'a`
The text was updated successfully, but these errors were encountered:
I would expect that it's possible to create multiple prepared statements for a single connection at once like following:
This fails because to create a prepared statement it is required to borrow the connection mutably, which implies that you can only create one prepared statement per connection at one point in time.
This disallows common patterns like a prepared statement cache.
Error message:
The text was updated successfully, but these errors were encountered: