use std::{ffi::CStr, sync::OnceLock};
static VERSION: OnceLock<String> = OnceLock::new();
pub fn version() -> &'static str {
VERSION.get_or_init(|| {
unsafe {
let mut s = mlxrs_sys::mlx_string_new();
let rc = mlxrs_sys::mlx_version(&mut s);
assert_eq!(rc, 0, "mlx_version returned {rc}");
let data = mlxrs_sys::mlx_string_data(s);
assert!(!data.is_null(), "mlx_string_data returned NULL");
let owned = CStr::from_ptr(data).to_string_lossy().into_owned();
let _ = mlxrs_sys::mlx_string_free(s);
owned
}
})
}