Move a macro

This commit is contained in:
Ivan Ukhov
2015-06-19 20:23:12 -04:00
parent 827386c588
commit d8835fec8c
2 changed files with 11 additions and 14 deletions

View File

@ -126,13 +126,6 @@ extern fn process_callback<F>(callback: *mut c_void, count: c_int, values: *mut
columns: *mut *mut c_char) -> c_int
where F: FnMut(&[(&str, Option<&str>)]) -> bool
{
use std::str;
use std::ffi::CStr;
macro_rules! c_str_to_str(
($string:expr) => (str::from_utf8(CStr::from_ptr($string).to_bytes()));
);
unsafe {
let mut pairs = Vec::with_capacity(count as usize);

View File

@ -66,6 +66,17 @@ macro_rules! path_to_c_str(
});
);
macro_rules! c_str_to_str(
($string:expr) => (::std::str::from_utf8(::std::ffi::CStr::from_ptr($string).to_bytes()));
);
macro_rules! c_str_to_string(
($string:expr) => (
String::from_utf8_lossy(::std::ffi::CStr::from_ptr($string as *const _).to_bytes())
.into_owned()
);
);
macro_rules! str_to_c_str(
($string:expr) => (
match ::std::ffi::CString::new($string) {
@ -75,13 +86,6 @@ macro_rules! str_to_c_str(
);
);
macro_rules! c_str_to_string(
($cstr:expr) => (
String::from_utf8_lossy(::std::ffi::CStr::from_ptr($cstr as *const _).to_bytes())
.into_owned()
);
);
mod database;
mod error;
mod statement;