mirror of
https://github.com/isar/rusqlite.git
synced 2024-11-26 19:41:37 +08:00
Merge pull request #213 from jgallagher/fix-clippy-warnings
Fix clippy warnings
This commit is contained in:
commit
2b78e956dc
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "rusqlite"
|
name = "rusqlite"
|
||||||
version = "0.9.2"
|
version = "0.9.3"
|
||||||
authors = ["John Gallagher <jgallagher@bignerdranch.com>"]
|
authors = ["John Gallagher <jgallagher@bignerdranch.com>"]
|
||||||
description = "Ergonomic wrapper for SQLite"
|
description = "Ergonomic wrapper for SQLite"
|
||||||
repository = "https://github.com/jgallagher/rusqlite"
|
repository = "https://github.com/jgallagher/rusqlite"
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
# Version 0.9.3 (2017-01-23)
|
||||||
|
|
||||||
|
* Make `ToSqlOutput` itself implement `ToSql`.
|
||||||
|
|
||||||
# Version 0.9.2 (2017-01-22)
|
# Version 0.9.2 (2017-01-22)
|
||||||
|
|
||||||
* Bugfix: The `FromSql` impl for `i32` now returns an error instead of
|
* Bugfix: The `FromSql` impl for `i32` now returns an error instead of
|
||||||
|
@ -908,7 +908,7 @@ impl<'conn> Statement<'conn> {
|
|||||||
ValueRef::Null => unsafe { ffi::sqlite3_bind_null(ptr, col) },
|
ValueRef::Null => unsafe { ffi::sqlite3_bind_null(ptr, col) },
|
||||||
ValueRef::Integer(i) => unsafe { ffi::sqlite3_bind_int64(ptr, col, i) },
|
ValueRef::Integer(i) => unsafe { ffi::sqlite3_bind_int64(ptr, col, i) },
|
||||||
ValueRef::Real(r) => unsafe { ffi::sqlite3_bind_double(ptr, col, r) },
|
ValueRef::Real(r) => unsafe { ffi::sqlite3_bind_double(ptr, col, r) },
|
||||||
ValueRef::Text(ref s) => unsafe {
|
ValueRef::Text(s) => unsafe {
|
||||||
let length = s.len();
|
let length = s.len();
|
||||||
if length > ::std::i32::MAX as usize {
|
if length > ::std::i32::MAX as usize {
|
||||||
ffi::SQLITE_TOOBIG
|
ffi::SQLITE_TOOBIG
|
||||||
@ -922,7 +922,7 @@ impl<'conn> Statement<'conn> {
|
|||||||
ffi::sqlite3_bind_text(ptr, col, c_str.as_ptr(), length as c_int, destructor)
|
ffi::sqlite3_bind_text(ptr, col, c_str.as_ptr(), length as c_int, destructor)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ValueRef::Blob(ref b) => unsafe {
|
ValueRef::Blob(b) => unsafe {
|
||||||
let length = b.len();
|
let length = b.len();
|
||||||
if length > ::std::i32::MAX as usize {
|
if length > ::std::i32::MAX as usize {
|
||||||
ffi::SQLITE_TOOBIG
|
ffi::SQLITE_TOOBIG
|
||||||
|
@ -38,9 +38,9 @@ impl Error for FromSqlError {
|
|||||||
#[cfg_attr(feature="clippy", allow(match_same_arms))]
|
#[cfg_attr(feature="clippy", allow(match_same_arms))]
|
||||||
fn cause(&self) -> Option<&Error> {
|
fn cause(&self) -> Option<&Error> {
|
||||||
match *self {
|
match *self {
|
||||||
FromSqlError::InvalidType => None,
|
|
||||||
FromSqlError::OutOfRange(_) => None,
|
|
||||||
FromSqlError::Other(ref err) => err.cause(),
|
FromSqlError::Other(ref err) => err.cause(),
|
||||||
|
FromSqlError::InvalidType |
|
||||||
|
FromSqlError::OutOfRange(_) => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,18 @@ impl<'a, T: Into<Value>> From<T> for ToSqlOutput<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> ToSql for ToSqlOutput<'a> {
|
||||||
|
fn to_sql(&self) -> Result<ToSqlOutput> {
|
||||||
|
Ok(match *self {
|
||||||
|
ToSqlOutput::Borrowed(v) => ToSqlOutput::Borrowed(v),
|
||||||
|
ToSqlOutput::Owned(ref v) => ToSqlOutput::Borrowed(ValueRef::from(v)),
|
||||||
|
|
||||||
|
#[cfg(feature = "blob")]
|
||||||
|
ToSqlOutput::ZeroBlob(i) => ToSqlOutput::ZeroBlob(i),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// A trait for types that can be converted into SQLite values.
|
/// A trait for types that can be converted into SQLite values.
|
||||||
pub trait ToSql {
|
pub trait ToSql {
|
||||||
fn to_sql(&self) -> Result<ToSqlOutput>;
|
fn to_sql(&self) -> Result<ToSqlOutput>;
|
||||||
|
@ -54,7 +54,7 @@ impl<'a> ValueRef<'a> {
|
|||||||
/// `Err(Error::InvalidColumnType)`.
|
/// `Err(Error::InvalidColumnType)`.
|
||||||
pub fn as_str(&self) -> FromSqlResult<&str> {
|
pub fn as_str(&self) -> FromSqlResult<&str> {
|
||||||
match *self {
|
match *self {
|
||||||
ValueRef::Text(ref t) => Ok(t),
|
ValueRef::Text(t) => Ok(t),
|
||||||
_ => Err(FromSqlError::InvalidType),
|
_ => Err(FromSqlError::InvalidType),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -63,7 +63,7 @@ impl<'a> ValueRef<'a> {
|
|||||||
/// `Err(Error::InvalidColumnType)`.
|
/// `Err(Error::InvalidColumnType)`.
|
||||||
pub fn as_blob(&self) -> FromSqlResult<&[u8]> {
|
pub fn as_blob(&self) -> FromSqlResult<&[u8]> {
|
||||||
match *self {
|
match *self {
|
||||||
ValueRef::Blob(ref b) => Ok(b),
|
ValueRef::Blob(b) => Ok(b),
|
||||||
_ => Err(FromSqlError::InvalidType),
|
_ => Err(FromSqlError::InvalidType),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user