From: Eric Sunshine Date: Wed, 09 Oct 2024 06:18:24 GMT Subject: Re: [PATCH v4 4/5] libgit: add higher-level libgit crate Message-ID: In-Reply-To: <29599e9c7be1737bcf0de0541c9635212a1b691d.1728429158.git.steadmon@google.com> On Tue, Oct 8, 2024 at 7:19 PM Josh Steadmon wrote: > Wrap `struct config_set` and a few of its associated functions in > libgit-sys. Also introduce a higher-level "libgit" crate which provides > a more Rust-friendly interface to config_set structs. > > Signed-off-by: Calvin Wan > Signed-off-by: Josh Steadmon > --- > diff --git a/contrib/libgit-rs/src/lib.rs b/contrib/libgit-rs/src/lib.rs > @@ -0,0 +1,95 @@ > +pub struct ConfigSet(*mut libgit_config_set); > +impl ConfigSet { > + pub fn get_int(&mut self, key: &str) -> Option { > + let key = CString::new(key).expect("Couldn't convert to CString"); > + let mut val: c_int = 0; > + unsafe { > + if libgit_configset_get_int(self.0, key.as_ptr(), &mut val as *mut c_int) != 0 { > + return None; > + } > + } > + Some(val) > + } Considering that v4 finally gets around to swapping out `CString` for `String` in order to make this high-level crate more Rust-programmer-friendly, I was more than a little surprised to see that this function is still exposing `c_int` rather than, say, `i64` or such.