From ff02213b531d5346b1ee9c1a252f266a1849db4f Mon Sep 17 00:00:00 2001 From: Gwenael Treguier Date: Wed, 16 Dec 2015 20:10:31 +0100 Subject: [PATCH] Introduce a RefCell in CachedStatement. --- src/cache.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/cache.rs b/src/cache.rs index 38a5e38..aa78e5a 100644 --- a/src/cache.rs +++ b/src/cache.rs @@ -1,6 +1,7 @@ //! Prepared statements cache for faster execution. extern crate lru_cache; +use std::cell::RefCell; use {Result, Connection, Statement}; use self::lru_cache::LruCache; @@ -15,7 +16,7 @@ pub struct StatementCache<'conn> { pub struct CachedStatement<'conn> { stmt: Statement<'conn>, - cache: &'conn StatementCache<'conn>, + cache: RefCell>, pub cacheable : bool, } @@ -23,8 +24,8 @@ impl<'conn> Drop for CachedStatement<'conn> { #[allow(unused_must_use)] fn drop(&mut self) { if self.cacheable { - // FIXME cannot borrow immutable borrowed content `*self.cache` as mutable - //self.cache.release(self.stmt, false); + // FIXME: cannot move out of type `cache::CachedStatement<'conn>`, which defines the `Drop` trait [E0509] + //self.cache.borrow_mut().release(self.stmt, false); } else { self.stmt.finalize_(); }