diff --git a/src/lib.rs b/src/lib.rs index 49d9248..c7ad659 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -48,15 +48,12 @@ //! } //! } //! ``` -#![feature(unique)] -#![cfg_attr(test, feature(test))] - extern crate libc; extern crate libsqlite3_sys as ffi; #[macro_use] extern crate bitflags; use std::mem; -use std::ptr::{self, Unique}; +use std::ptr; use std::fmt; use std::path::{Path}; use std::error; @@ -153,6 +150,8 @@ pub struct SqliteConnection { db: RefCell, } +unsafe impl Send for SqliteConnection {} + impl SqliteConnection { /// Open a new connection to a SQLite database. /// @@ -419,7 +418,7 @@ impl fmt::Debug for SqliteConnection { } struct InnerSqliteConnection { - db: Unique, + db: *mut ffi::Struct_sqlite3, } bitflags! { @@ -463,12 +462,12 @@ impl InnerSqliteConnection { ffi::sqlite3_close(db); return Err(e); } - Ok(InnerSqliteConnection{ db: Unique::new(db) }) + Ok(InnerSqliteConnection{ db: db }) } } fn db(&self) -> *mut ffi::Struct_sqlite3 { - unsafe {self.db.get() as *const _ as *mut _} + self.db } fn decode_result(&mut self, code: c_int) -> SqliteResult<()> { @@ -492,7 +491,7 @@ impl InnerSqliteConnection { fn close(&mut self) -> SqliteResult<()> { unsafe { let r = ffi::sqlite3_close(self.db()); - self.db = Unique::new(ptr::null_mut()); + self.db = ptr::null_mut(); self.decode_result(r) } } diff --git a/src/transaction.rs b/src/transaction.rs index a994532..1882539 100644 --- a/src/transaction.rs +++ b/src/transaction.rs @@ -158,7 +158,6 @@ impl<'conn> Drop for SqliteTransaction<'conn> { #[cfg(test)] mod test { - extern crate test; use SqliteConnection; fn checked_memory_handle() -> SqliteConnection { @@ -231,32 +230,4 @@ mod test { } assert_eq!(3i32, db.query_row("SELECT SUM(x) FROM foo", &[], |r| r.get(0))); } - - #[bench] - fn test_no_transaction_insert(bencher: &mut test::Bencher) { - let db = checked_memory_handle(); - - let mut stmt = db.prepare("INSERT INTO foo VALUES(1)").unwrap(); - - bencher.iter(|| { - for _ in 0i32 .. 1000 { - stmt.execute(&[]).unwrap(); - } - }) - } - - #[bench] - fn test_transaction_insert(bencher: &mut test::Bencher) { - let db = checked_memory_handle(); - - let mut stmt = db.prepare("INSERT INTO foo VALUES(1)").unwrap(); - - bencher.iter(|| { - let mut tx = db.transaction().unwrap(); - tx.set_commit(); - for _ in 0i32 .. 1000 { - stmt.execute(&[]).unwrap(); - } - }) - } }