mirror of
https://github.com/isar/rusqlite.git
synced 2024-11-25 10:31:37 +08:00
rustfmt v0.7.1
This commit is contained in:
parent
4a057480c1
commit
80f822db28
@ -89,11 +89,7 @@ impl Connection {
|
||||
table.as_ptr(),
|
||||
column.as_ptr(),
|
||||
row,
|
||||
if read_only {
|
||||
0
|
||||
} else {
|
||||
1
|
||||
},
|
||||
if read_only { 0 } else { 1 },
|
||||
&mut blob)
|
||||
};
|
||||
c.decode_result(rc).map(|_| {
|
||||
|
@ -141,9 +141,7 @@ impl error::Error for Error {
|
||||
"SQLite was compiled or configured for single-threaded use only"
|
||||
}
|
||||
Error::FromSqlConversionFailure(_, _, ref err) => err.description(),
|
||||
Error::IntegralValueOutOfRange(_, _) => {
|
||||
"integral value out of range of requested type"
|
||||
}
|
||||
Error::IntegralValueOutOfRange(_, _) => "integral value out of range of requested type",
|
||||
Error::Utf8Error(ref err) => err.description(),
|
||||
Error::InvalidParameterName(_) => "invalid parameter name",
|
||||
Error::NulError(ref err) => err.description(),
|
||||
|
@ -228,11 +228,7 @@ impl<'a> Context<'a> {
|
||||
/// types must be identical.
|
||||
pub unsafe fn get_aux<T>(&self, arg: c_int) -> Option<&T> {
|
||||
let p = ffi::sqlite3_get_auxdata(self.ctx, arg) as *mut T;
|
||||
if p.is_null() {
|
||||
None
|
||||
} else {
|
||||
Some(&*p)
|
||||
}
|
||||
if p.is_null() { None } else { Some(&*p) }
|
||||
}
|
||||
}
|
||||
|
||||
@ -670,7 +666,8 @@ mod test {
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
for &(expected, query) in &[("", "SELECT my_concat()"),
|
||||
for &(expected, query) in
|
||||
&[("", "SELECT my_concat()"),
|
||||
("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();
|
||||
|
31
src/lib.rs
31
src/lib.rs
@ -103,12 +103,18 @@ mod named_params;
|
||||
mod error;
|
||||
mod convenient;
|
||||
mod raw_statement;
|
||||
#[cfg(feature = "load_extension")]mod load_extension_guard;
|
||||
#[cfg(feature = "trace")]pub mod trace;
|
||||
#[cfg(feature = "backup")]pub mod backup;
|
||||
#[cfg(feature = "functions")]pub mod functions;
|
||||
#[cfg(feature = "blob")]pub mod blob;
|
||||
#[cfg(feature = "limits")]pub mod limits;
|
||||
#[cfg(feature = "load_extension")]
|
||||
mod load_extension_guard;
|
||||
#[cfg(feature = "trace")]
|
||||
pub mod trace;
|
||||
#[cfg(feature = "backup")]
|
||||
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.
|
||||
const STATEMENT_CACHE_DEFAULT_CAPACITY: usize = 16;
|
||||
@ -1067,8 +1073,7 @@ impl<'stmt> Rows<'stmt> {
|
||||
/// "streaming iterator". For a more natural interface, consider using `query_map`
|
||||
/// or `query_and_then` instead, which return types that implement `Iterator`.
|
||||
pub fn next<'a>(&'a mut self) -> Option<Result<Row<'a, 'stmt>>> {
|
||||
self.stmt.and_then(|stmt| {
|
||||
match stmt.stmt.step() {
|
||||
self.stmt.and_then(|stmt| match stmt.stmt.step() {
|
||||
ffi::SQLITE_ROW => {
|
||||
Some(Ok(Row {
|
||||
stmt: stmt,
|
||||
@ -1083,7 +1088,6 @@ impl<'stmt> Rows<'stmt> {
|
||||
self.reset();
|
||||
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 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 {
|
||||
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))
|
||||
} 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(&[])
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ use std::borrow::Cow;
|
||||
|
||||
use self::chrono::{NaiveDate, NaiveTime, NaiveDateTime, DateTime, TimeZone, UTC, Local};
|
||||
|
||||
use ::Result;
|
||||
use Result;
|
||||
use types::{FromSql, FromSqlError, FromSqlResult, ToSql, ToSqlOutput, ValueRef};
|
||||
|
||||
/// ISO 8601 calendar date without timezone => "YYYY-MM-DD"
|
||||
|
@ -3,7 +3,7 @@ extern crate serde_json;
|
||||
|
||||
use self::serde_json::Value;
|
||||
|
||||
use ::Result;
|
||||
use Result;
|
||||
use types::{FromSql, FromSqlError, FromSqlResult, ToSql, ToSqlOutput, ValueRef};
|
||||
|
||||
/// Serialize JSON `Value` to text.
|
||||
|
@ -1,5 +1,5 @@
|
||||
use super::{Null, Value, ValueRef};
|
||||
use ::Result;
|
||||
use Result;
|
||||
|
||||
/// `ToSqlOutput` represents the possible output types for implementors of the `ToSql` trait.
|
||||
#[derive(Clone,Debug,PartialEq)]
|
||||
|
@ -1,4 +1,4 @@
|
||||
use ::types::{FromSqlError, FromSqlResult};
|
||||
use types::{FromSqlError, FromSqlResult};
|
||||
use super::{Value, Type};
|
||||
|
||||
/// A non-owning [dynamic type value](http://sqlite.org/datatype3.html). Typically the
|
||||
|
@ -1,7 +1,8 @@
|
||||
//! 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.
|
||||
|
||||
#[macro_use] extern crate lazy_static;
|
||||
#[macro_use]
|
||||
extern crate lazy_static;
|
||||
extern crate libc;
|
||||
extern crate rusqlite;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user