pyo3/python3-sys/examples/version.rs

16 lines
339 B
Rust
Raw Normal View History

2015-04-26 08:32:58 +00:00
extern crate libc;
extern crate python3_sys;
unsafe fn get_str<'a>(s: *const libc::c_char) -> &'a str {
let bytes = std::ffi::CStr::from_ptr(s).to_bytes();
std::str::from_utf8(bytes).unwrap()
}
fn main() {
unsafe {
python3_sys::Py_Initialize();
println!("{}", get_str(python3_sys::Py_GetVersion()));
}
}