rustfmt v0.7.1

This commit is contained in:
gwenn 2017-02-08 21:11:15 +01:00
parent 4a057480c1
commit 80f822db28
9 changed files with 50 additions and 51 deletions

View File

@ -89,11 +89,7 @@ impl Connection {
table.as_ptr(), table.as_ptr(),
column.as_ptr(), column.as_ptr(),
row, row,
if read_only { if read_only { 0 } else { 1 },
0
} else {
1
},
&mut blob) &mut blob)
}; };
c.decode_result(rc).map(|_| { c.decode_result(rc).map(|_| {
@ -273,7 +269,7 @@ mod test {
let mut blob = db.blob_open(DatabaseName::Main, "test", "content", rowid, false).unwrap(); let mut blob = db.blob_open(DatabaseName::Main, "test", "content", rowid, false).unwrap();
assert_eq!(4, blob.write(b"Clob").unwrap()); assert_eq!(4, blob.write(b"Clob").unwrap());
assert_eq!(6, blob.write(b"567890xxxxxx").unwrap()); // cannot write past 10 assert_eq!(6, blob.write(b"567890xxxxxx").unwrap()); // cannot write past 10
assert_eq!(0, blob.write(b"5678").unwrap()); // still cannot write past 10 assert_eq!(0, blob.write(b"5678").unwrap()); // still cannot write past 10
blob.reopen(rowid).unwrap(); blob.reopen(rowid).unwrap();
blob.close().unwrap(); blob.close().unwrap();

View File

@ -141,9 +141,7 @@ impl error::Error for Error {
"SQLite was compiled or configured for single-threaded use only" "SQLite was compiled or configured for single-threaded use only"
} }
Error::FromSqlConversionFailure(_, _, ref err) => err.description(), Error::FromSqlConversionFailure(_, _, ref err) => err.description(),
Error::IntegralValueOutOfRange(_, _) => { Error::IntegralValueOutOfRange(_, _) => "integral value out of range of requested type",
"integral value out of range of requested type"
}
Error::Utf8Error(ref err) => err.description(), Error::Utf8Error(ref err) => err.description(),
Error::InvalidParameterName(_) => "invalid parameter name", Error::InvalidParameterName(_) => "invalid parameter name",
Error::NulError(ref err) => err.description(), Error::NulError(ref err) => err.description(),

View File

@ -228,11 +228,7 @@ impl<'a> Context<'a> {
/// types must be identical. /// types must be identical.
pub unsafe fn get_aux<T>(&self, arg: c_int) -> Option<&T> { pub unsafe fn get_aux<T>(&self, arg: c_int) -> Option<&T> {
let p = ffi::sqlite3_get_auxdata(self.ctx, arg) as *mut T; let p = ffi::sqlite3_get_auxdata(self.ctx, arg) as *mut T;
if p.is_null() { if p.is_null() { None } else { Some(&*p) }
None
} else {
Some(&*p)
}
} }
} }
@ -670,9 +666,10 @@ mod test {
}) })
.unwrap(); .unwrap();
for &(expected, query) in &[("", "SELECT my_concat()"), for &(expected, query) in
("onetwo", "SELECT my_concat('one', 'two')"), &[("", "SELECT my_concat()"),
("abc", "SELECT my_concat('a', 'b', 'c')")] { ("onetwo", "SELECT my_concat('one', 'two')"),
("abc", "SELECT my_concat('a', 'b', 'c')")] {
let result: String = db.query_row(query, &[], |r| r.get(0)).unwrap(); let result: String = db.query_row(query, &[], |r| r.get(0)).unwrap();
assert_eq!(expected, result); assert_eq!(expected, result);
} }

View File

@ -103,12 +103,18 @@ mod named_params;
mod error; mod error;
mod convenient; mod convenient;
mod raw_statement; mod raw_statement;
#[cfg(feature = "load_extension")]mod load_extension_guard; #[cfg(feature = "load_extension")]
#[cfg(feature = "trace")]pub mod trace; mod load_extension_guard;
#[cfg(feature = "backup")]pub mod backup; #[cfg(feature = "trace")]
#[cfg(feature = "functions")]pub mod functions; pub mod trace;
#[cfg(feature = "blob")]pub mod blob; #[cfg(feature = "backup")]
#[cfg(feature = "limits")]pub mod limits; pub mod backup;
#[cfg(feature = "functions")]
pub mod functions;
#[cfg(feature = "blob")]
pub mod blob;
#[cfg(feature = "limits")]
pub mod limits;
// Number of cached prepared statements we'll hold on to. // Number of cached prepared statements we'll hold on to.
const STATEMENT_CACHE_DEFAULT_CAPACITY: usize = 16; const STATEMENT_CACHE_DEFAULT_CAPACITY: usize = 16;
@ -417,10 +423,10 @@ impl Connection {
pub fn close(self) -> std::result::Result<(), (Connection, Error)> { pub fn close(self) -> std::result::Result<(), (Connection, Error)> {
self.flush_prepared_statement_cache(); self.flush_prepared_statement_cache();
{ {
let mut db = self.db.borrow_mut(); let mut db = self.db.borrow_mut();
db.close() db.close()
} }
.map_err(move |err| (self, err)) .map_err(move |err| (self, err))
} }
/// Enable loading of SQLite extensions. Strongly consider using `LoadExtensionGuard` /// Enable loading of SQLite extensions. Strongly consider using `LoadExtensionGuard`
@ -1067,22 +1073,20 @@ impl<'stmt> Rows<'stmt> {
/// "streaming iterator". For a more natural interface, consider using `query_map` /// "streaming iterator". For a more natural interface, consider using `query_map`
/// or `query_and_then` instead, which return types that implement `Iterator`. /// or `query_and_then` instead, which return types that implement `Iterator`.
pub fn next<'a>(&'a mut self) -> Option<Result<Row<'a, 'stmt>>> { pub fn next<'a>(&'a mut self) -> Option<Result<Row<'a, 'stmt>>> {
self.stmt.and_then(|stmt| { self.stmt.and_then(|stmt| match stmt.stmt.step() {
match stmt.stmt.step() { ffi::SQLITE_ROW => {
ffi::SQLITE_ROW => { Some(Ok(Row {
Some(Ok(Row { stmt: stmt,
stmt: stmt, phantom: PhantomData,
phantom: PhantomData, }))
})) }
} ffi::SQLITE_DONE => {
ffi::SQLITE_DONE => { self.reset();
self.reset(); None
None }
} code => {
code => { self.reset();
self.reset(); Some(Err(stmt.conn.decode_result(code).unwrap_err()))
Some(Err(stmt.conn.decode_result(code).unwrap_err()))
}
} }
}) })
} }
@ -1197,12 +1201,15 @@ impl<'a> ValueRef<'a> {
let blob = ffi::sqlite3_column_blob(raw, col); let blob = ffi::sqlite3_column_blob(raw, col);
let len = ffi::sqlite3_column_bytes(raw, col); let len = ffi::sqlite3_column_bytes(raw, col);
assert!(len >= 0, "unexpected negative return from sqlite3_column_bytes"); assert!(len >= 0,
"unexpected negative return from sqlite3_column_bytes");
if len > 0 { if len > 0 {
assert!(!blob.is_null(), "unexpected SQLITE_BLOB column type with NULL data"); assert!(!blob.is_null(),
"unexpected SQLITE_BLOB column type with NULL data");
ValueRef::Blob(from_raw_parts(blob as *const u8, len as usize)) ValueRef::Blob(from_raw_parts(blob as *const u8, len as usize))
} else { } else {
// The return value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer. // The return value from sqlite3_column_blob() for a zero-length BLOB
// is a NULL pointer.
ValueRef::Blob(&[]) ValueRef::Blob(&[])
} }
} }

View File

@ -5,7 +5,7 @@ use std::borrow::Cow;
use self::chrono::{NaiveDate, NaiveTime, NaiveDateTime, DateTime, TimeZone, UTC, Local}; use self::chrono::{NaiveDate, NaiveTime, NaiveDateTime, DateTime, TimeZone, UTC, Local};
use ::Result; use Result;
use types::{FromSql, FromSqlError, FromSqlResult, ToSql, ToSqlOutput, ValueRef}; use types::{FromSql, FromSqlError, FromSqlResult, ToSql, ToSqlOutput, ValueRef};
/// ISO 8601 calendar date without timezone => "YYYY-MM-DD" /// ISO 8601 calendar date without timezone => "YYYY-MM-DD"

View File

@ -3,7 +3,7 @@ extern crate serde_json;
use self::serde_json::Value; use self::serde_json::Value;
use ::Result; use Result;
use types::{FromSql, FromSqlError, FromSqlResult, ToSql, ToSqlOutput, ValueRef}; use types::{FromSql, FromSqlError, FromSqlResult, ToSql, ToSqlOutput, ValueRef};
/// Serialize JSON `Value` to text. /// Serialize JSON `Value` to text.

View File

@ -1,5 +1,5 @@
use super::{Null, Value, ValueRef}; use super::{Null, Value, ValueRef};
use ::Result; use Result;
/// `ToSqlOutput` represents the possible output types for implementors of the `ToSql` trait. /// `ToSqlOutput` represents the possible output types for implementors of the `ToSql` trait.
#[derive(Clone,Debug,PartialEq)] #[derive(Clone,Debug,PartialEq)]

View File

@ -1,4 +1,4 @@
use ::types::{FromSqlError, FromSqlResult}; use types::{FromSqlError, FromSqlResult};
use super::{Value, Type}; use super::{Value, Type};
/// A non-owning [dynamic type value](http://sqlite.org/datatype3.html). Typically the /// A non-owning [dynamic type value](http://sqlite.org/datatype3.html). Typically the

View File

@ -1,7 +1,8 @@
//! This file contains unit tests for rusqlite::trace::config_log. This function affects //! This file contains unit tests for rusqlite::trace::config_log. This function affects
//! SQLite process-wide and so is not safe to run as a normal #[test] in the library. //! SQLite process-wide and so is not safe to run as a normal #[test] in the library.
#[macro_use] extern crate lazy_static; #[macro_use]
extern crate lazy_static;
extern crate libc; extern crate libc;
extern crate rusqlite; extern crate rusqlite;