Re: [PATCH v3 06/15] ivec: create a vector type that is interoperable between C and Rust
- From
Ezekiel Newren <ezekielnewren@gmail.com>
- Date
- Aug 23, 2025, 09:29 UTC
- Message-ID
- <CAH=ZcbBCg8837kN9LjvdRtgVWL9vP=EDYw04wEPZxO6NLscbGg@mail.gmail.com>
- In-Reply-To
- <ed31658a-9241-4d75-a086-633448b711a4@app.fastmail.com>
On Sat, Aug 23, 2025 at 2:13 AM Kristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com> wrote:
Show 25 quoted lines
>
> On Sat, Aug 23, 2025, at 05:55, Ezekiel Newren via GitGitGadget wrote:
> > From: Ezekiel Newren <ezekielnewren@gmail.com>
> >
> > Trying to use Rust's Vec in C, or git's ALLOC_GROW() macros (via
> > wrapper functions) in Rust is painful because:
>
> nit: s/git's/Git's/
>
> > [snip]
> > diff --git a/rust/interop/src/ivec.rs b/rust/interop/src/ivec.rs
> > [snip]
> > + // assert_eq!(vec.capacity, vec.slice.len());
>
> Why are there three commented-out assertions? (all capacity/length)
>
> > + assert_eq!(expected, vec.length);
> > + assert!(vec.capacity >= expected);
> > + for i in 0..vec.length {
> > + assert_eq!(default_value, vec[i]);
> > + }
> > [snip]
>
> --
> Kristoffer HaugsbakkGood catch, I should have removed those commented out lines. Looking back through the code I also missed calling std::ptr::drop_in_place() if the IVec shrinks. I'll apply those changes in the next version.