Adjust the formatting of the macros

This commit is contained in:
Ivan Ukhov 2017-08-23 10:09:04 +02:00
parent 742837660d
commit 9aba31e37c
2 changed files with 42 additions and 30 deletions

View File

@ -115,27 +115,33 @@ macro_rules! raise(
);
macro_rules! error(
($connection:expr, $code:expr) => (match ::last_error($connection) {
Some(error) => return Err(error),
_ => return Err(::Error {
code: Some($code as isize),
message: None,
}),
});
($connection:expr, $code:expr) => (
match ::last_error($connection) {
Some(error) => return Err(error),
_ => return Err(::Error {
code: Some($code as isize),
message: None,
}),
}
);
);
macro_rules! ok(
($connection:expr, $result:expr) => (match $result {
::ffi::SQLITE_OK => {}
code => error!($connection, code),
});
($result:expr) => (match $result {
::ffi::SQLITE_OK => {}
code => return Err(::Error {
code: Some(code as isize),
message: None,
}),
});
($connection:expr, $result:expr) => (
match $result {
::ffi::SQLITE_OK => {}
code => error!($connection, code),
}
);
($result:expr) => (
match $result {
::ffi::SQLITE_OK => {}
code => return Err(::Error {
code: Some(code as isize),
message: None,
}),
}
);
);
macro_rules! c_str_to_str(
@ -150,22 +156,26 @@ macro_rules! c_str_to_string(
);
macro_rules! path_to_cstr(
($path:expr) => (match $path.to_str() {
Some(path) => {
match ::std::ffi::CString::new(path) {
Ok(string) => string,
_ => raise!("failed to process a path"),
($path:expr) => (
match $path.to_str() {
Some(path) => {
match ::std::ffi::CString::new(path) {
Ok(string) => string,
_ => raise!("failed to process a path"),
}
}
_ => raise!("failed to process a path"),
}
_ => raise!("failed to process a path"),
});
);
);
macro_rules! str_to_cstr(
($string:expr) => (match ::std::ffi::CString::new($string) {
Ok(string) => string,
_ => raise!("failed to process a string"),
});
($string:expr) => (
match ::std::ffi::CString::new($string) {
Ok(string) => string,
_ => raise!("failed to process a string"),
}
);
);
/// An error.

View File

@ -5,7 +5,9 @@ use std::marker::PhantomData;
use {Cursor, Result, Type, Value};
// https://sqlite.org/c3ref/c_static.html
macro_rules! transient(() => (::std::mem::transmute(!0 as *const ::libc::c_void)));
macro_rules! transient(
() => (::std::mem::transmute(!0 as *const ::libc::c_void));
);
/// A prepared statement.
pub struct Statement<'l> {