mirror of
https://github.com/isar/rusqlite.git
synced 2024-11-23 09:09:19 +08:00
Introduce a RefCell in CachedStatement.
This commit is contained in:
parent
9257987b37
commit
ff02213b53
@ -1,6 +1,7 @@
|
|||||||
//! Prepared statements cache for faster execution.
|
//! Prepared statements cache for faster execution.
|
||||||
extern crate lru_cache;
|
extern crate lru_cache;
|
||||||
|
|
||||||
|
use std::cell::RefCell;
|
||||||
use {Result, Connection, Statement};
|
use {Result, Connection, Statement};
|
||||||
use self::lru_cache::LruCache;
|
use self::lru_cache::LruCache;
|
||||||
|
|
||||||
@ -15,7 +16,7 @@ pub struct StatementCache<'conn> {
|
|||||||
|
|
||||||
pub struct CachedStatement<'conn> {
|
pub struct CachedStatement<'conn> {
|
||||||
stmt: Statement<'conn>,
|
stmt: Statement<'conn>,
|
||||||
cache: &'conn StatementCache<'conn>,
|
cache: RefCell<StatementCache<'conn>>,
|
||||||
pub cacheable : bool,
|
pub cacheable : bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,8 +24,8 @@ impl<'conn> Drop for CachedStatement<'conn> {
|
|||||||
#[allow(unused_must_use)]
|
#[allow(unused_must_use)]
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
if self.cacheable {
|
if self.cacheable {
|
||||||
// FIXME cannot borrow immutable borrowed content `*self.cache` as mutable
|
// FIXME: cannot move out of type `cache::CachedStatement<'conn>`, which defines the `Drop` trait [E0509]
|
||||||
//self.cache.release(self.stmt, false);
|
//self.cache.borrow_mut().release(self.stmt, false);
|
||||||
} else {
|
} else {
|
||||||
self.stmt.finalize_();
|
self.stmt.finalize_();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user