Re: [PATCH v4 4/5] libgit: add higher-level libgit crate
On 2024.10.09 02:18, Eric Sunshine wrote:
Show 28 quoted lines
> On Tue, Oct 8, 2024 at 7:19 PM Josh Steadmon <steadmon@google.com> 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 <calvinwan@google.com>
> > Signed-off-by: Josh Steadmon <steadmon@google.com>
> > ---
> > 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<c_int> {
> > + 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.Yes, definitely an oversight. I'll fix in V5.