mirror of
https://github.com/isar/rusqlite.git
synced 2025-08-20 21:09:31 +08:00
Rustfmt
This commit is contained in:
37
src/error.rs
37
src/error.rs
@@ -1,5 +1,5 @@
|
||||
use crate::types::Type;
|
||||
use crate::types::FromSqlError;
|
||||
use crate::types::Type;
|
||||
use crate::{errmsg_to_string, ffi};
|
||||
use std::error;
|
||||
use std::fmt;
|
||||
@@ -162,7 +162,8 @@ const UNKNOWN_COLUMN: usize = std::usize::MAX;
|
||||
/// to allow use of `get_raw(…).as_…()?` in callbacks that take `Error`.
|
||||
impl From<FromSqlError> for Error {
|
||||
fn from(err: FromSqlError) -> Error {
|
||||
// The error type requires index and type fields, but they aren't known in this context.
|
||||
// The error type requires index and type fields, but they aren't known in this
|
||||
// context.
|
||||
match err {
|
||||
FromSqlError::OutOfRange(val) => Error::IntegralValueOutOfRange(UNKNOWN_COLUMN, val),
|
||||
#[cfg(feature = "i128_blob")]
|
||||
@@ -190,20 +191,24 @@ impl fmt::Display for Error {
|
||||
f,
|
||||
"SQLite was compiled or configured for single-threaded use only"
|
||||
),
|
||||
Error::FromSqlConversionFailure(i, ref t, ref err) => if i != UNKNOWN_COLUMN {
|
||||
write!(
|
||||
f,
|
||||
"Conversion error from type {} at index: {}, {}",
|
||||
t, i, err
|
||||
)
|
||||
} else {
|
||||
err.fmt(f)
|
||||
},
|
||||
Error::IntegralValueOutOfRange(col, val) => if col != UNKNOWN_COLUMN {
|
||||
write!(f, "Integer {} out of range at index {}", val, col)
|
||||
} else {
|
||||
write!(f, "Integer {} out of range", val)
|
||||
},
|
||||
Error::FromSqlConversionFailure(i, ref t, ref err) => {
|
||||
if i != UNKNOWN_COLUMN {
|
||||
write!(
|
||||
f,
|
||||
"Conversion error from type {} at index: {}, {}",
|
||||
t, i, err
|
||||
)
|
||||
} else {
|
||||
err.fmt(f)
|
||||
}
|
||||
}
|
||||
Error::IntegralValueOutOfRange(col, val) => {
|
||||
if col != UNKNOWN_COLUMN {
|
||||
write!(f, "Integer {} out of range at index {}", val, col)
|
||||
} else {
|
||||
write!(f, "Integer {} out of range", val)
|
||||
}
|
||||
}
|
||||
Error::Utf8Error(ref err) => err.fmt(f),
|
||||
Error::NulError(ref err) => err.fmt(f),
|
||||
Error::InvalidParameterName(ref name) => write!(f, "Invalid parameter name: {}", name),
|
||||
|
@@ -236,8 +236,8 @@ fn free_boxed_hook<F>(p: *mut c_void) {
|
||||
mod test {
|
||||
use super::Action;
|
||||
use crate::Connection;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use lazy_static::lazy_static;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
|
||||
#[test]
|
||||
fn test_commit_hook() {
|
||||
|
@@ -122,9 +122,9 @@ impl Connection {
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use lazy_static::lazy_static;
|
||||
use std::sync::Mutex;
|
||||
use std::time::Duration;
|
||||
use lazy_static::lazy_static;
|
||||
|
||||
use crate::Connection;
|
||||
|
||||
|
Reference in New Issue
Block a user