use std::ffi::CString;
use std::path::BytesContainer;
use libc::{c_char, size_t};
use raw;
pub fn iter2cstrs<T, I>(i: I) -> (Vec<CString>,
Vec<*const c_char>,
raw::git_strarray)
where T: BytesContainer, I: Iterator<Item=T> {
let arr = i.map(|t| {
CString::from_slice(t.container_as_bytes())
}).collect::<Vec<CString>>();
let strarray = arr.iter().map(|c| c.as_ptr()).collect::<Vec<_>>();
let raw = raw::git_strarray {
strings: strarray.as_ptr() as *mut _,
count: strarray.len() as size_t,
};
(arr, strarray, raw)
}