Simplify in-memory examples

This commit is contained in:
Ivan Ukhov 2015-06-19 07:51:34 -04:00
parent e1be1eb3fd
commit dfe55f4953
3 changed files with 4 additions and 5 deletions

View File

@ -9,7 +9,7 @@ The package provides an interface to [SQLite][1].
```rust
use std::path::Path;
let database = sqlite::open(&Path::new(":memory:")).unwrap();
let database = sqlite::open(":memory:").unwrap();
database.execute(r#"
CREATE TABLE `users` (id INTEGER, name VARCHAR(255));

View File

@ -5,7 +5,7 @@
//! ```
//! use std::path::Path;
//!
//! let database = sqlite::open(&Path::new(":memory:")).unwrap();
//! let database = sqlite::open(":memory:").unwrap();
//!
//! database.execute(r#"
//! CREATE TABLE `users` (id INTEGER, name VARCHAR(255));
@ -99,7 +99,7 @@ pub type Result<T> = ::std::result::Result<T, Error>;
/// Open a connection to a new or existing database.
#[inline]
pub fn open<'l, P: std::convert::AsRef<std::path::Path>>(path: P) -> Result<Database<'l>> {
pub fn open<'l, P: AsRef<std::path::Path>>(path: P) -> Result<Database<'l>> {
Database::open(path)
}

View File

@ -9,13 +9,12 @@ macro_rules! ok(
fn workflow() {
use sqlite::Binding::*;
use sqlite::State;
use std::path::Path;
macro_rules! pair(
($one:expr, $two:expr) => (($one, Some($two)));
);
let database = ok!(sqlite::open(&Path::new(":memory:")));
let database = ok!(sqlite::open(":memory:"));
let sql = r#"CREATE TABLE `users` (id INTEGER, name VARCHAR(255), age REAL);"#;
ok!(database.execute(sql));