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

View File

@ -5,7 +5,9 @@ use std::marker::PhantomData;
use {Cursor, Result, Type, Value}; use {Cursor, Result, Type, Value};
// https://sqlite.org/c3ref/c_static.html // 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. /// A prepared statement.
pub struct Statement<'l> { pub struct Statement<'l> {