From fd36d98c856ad7b2ee5a4d6334ec4c29b75dec6d Mon Sep 17 00:00:00 2001 From: gwenn Date: Mon, 6 Jul 2015 20:24:27 +0200 Subject: [PATCH] Make SqliteOpenFlags implement Default. Activate URI and NO_MUTEX by default. --- src/lib.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index f3d1754..88a836a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -54,6 +54,7 @@ extern crate libc; extern crate libsqlite3_sys as ffi; #[macro_use] extern crate bitflags; +use std::default::Default; use std::mem; use std::ptr; use std::fmt; @@ -160,13 +161,13 @@ impl SqliteConnection { /// `SqliteConnection::open(path)` is equivalent to `SqliteConnection::open_with_flags(path, /// SQLITE_OPEN_READ_WRITE | SQLITE_OPEN_CREATE)`. pub fn open>(path: &P) -> SqliteResult { - let flags = SQLITE_OPEN_READ_WRITE | SQLITE_OPEN_CREATE; + let flags = Default::default(); SqliteConnection::open_with_flags(path, flags) } /// Open a new connection to an in-memory SQLite database. pub fn open_in_memory() -> SqliteResult { - let flags = SQLITE_OPEN_READ_WRITE | SQLITE_OPEN_CREATE; + let flags = Default::default(); SqliteConnection::open_in_memory_with_flags(flags) } @@ -435,6 +436,15 @@ bitflags! { } } +impl Default for SqliteOpenFlags { + fn default() -> SqliteOpenFlags { + SQLITE_OPEN_READ_WRITE + | SQLITE_OPEN_CREATE + | SQLITE_OPEN_NO_MUTEX + | SQLITE_OPEN_URI + } +} + impl InnerSqliteConnection { fn open_with_flags(c_path: &CString, flags: SqliteOpenFlags) -> SqliteResult {