From 09d77d950a68dc3022c0c75640a643230e864772 Mon Sep 17 00:00:00 2001 From: Josh Cunningham Date: Fri, 21 Nov 2025 12:33:51 -0600 Subject: [PATCH] add compat feature for unsafe get_value_ptr --- bmi-rs/Cargo.toml | 2 ++ bmi-rs/src/wrapper.rs | 20 ++++++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/bmi-rs/Cargo.toml b/bmi-rs/Cargo.toml index c514bac..bbb612a 100644 --- a/bmi-rs/Cargo.toml +++ b/bmi-rs/Cargo.toml @@ -11,6 +11,8 @@ license = "MIT" homepage = "https://github.com/aaraney/bmi-rs" repository = "https://github.com/aaraney/bmi-rs" +[features] +compat = [] [dependencies] ffi = { path = "../bmi-rs-sys", package = "bmi-rs-sys", version = "0.0.1" } diff --git a/bmi-rs/src/wrapper.rs b/bmi-rs/src/wrapper.rs index c04e839..f047c9d 100644 --- a/bmi-rs/src/wrapper.rs +++ b/bmi-rs/src/wrapper.rs @@ -356,17 +356,13 @@ pub extern "C" fn get_value( BMI_SUCCESS } -/// See -/// (#3)[https://github.com/aaraney/bmi-rs/issues/3] -/// for why this returns `BMI_FAILURE`. +#[cfg(feature = "compat")] #[allow(unused_variables)] pub extern "C" fn get_value_ptr( self_: *mut ffi::Bmi, name: *const c_char, dest: *mut *mut c_void, ) -> c_int { - BMI_FAILURE - /* let var_name = as_str_ref_or_fail!(name); let data: &mut T = data_field!(&self_); @@ -384,7 +380,19 @@ pub extern "C" fn get_value_ptr( }; unsafe { *dest = src }; BMI_SUCCESS - */ +} + +/// See +/// (#3)[https://github.com/aaraney/bmi-rs/issues/3] +/// for why this returns `BMI_FAILURE`. +#[cfg(not(feature = "compat"))] +#[allow(unused_variables)] +pub extern "C" fn get_value_ptr( + self_: *mut ffi::Bmi, + name: *const c_char, + dest: *mut *mut c_void, +) -> c_int { + BMI_FAILURE } pub extern "C" fn get_value_at_indices(