From 9aba31e37c42ce30bb8b94c3b52297a94baa9924 Mon Sep 17 00:00:00 2001 From: Ivan Ukhov Date: Wed, 23 Aug 2017 10:09:04 +0200 Subject: [PATCH] Adjust the formatting of the macros --- src/lib.rs | 68 +++++++++++++++++++++++++++--------------------- src/statement.rs | 4 ++- 2 files changed, 42 insertions(+), 30 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 70aa72f..1c43685 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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. diff --git a/src/statement.rs b/src/statement.rs index bf26881..7fef4a6 100644 --- a/src/statement.rs +++ b/src/statement.rs @@ -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> {