Re: [PATCH 4/7] xdiff: make fields of xrecord_t Rust friendly
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jul 28, 2025, 20:53 UTC
- Message-ID
- <xmqqwm7st4ts.fsf@gitster.g>
- In-Reply-To
- <a765cde9-0fad-414a-996f-2ec162d1e4f3@gmail.com>
Phillip Wood <phillip.wood123@gmail.com> writes:
Show 22 quoted lines
> On 28/07/2025 20:34, Ezekiel Newren wrote: >> On Fri, Jul 18, 2025 at 7:35 AM Phillip Wood <phillip.wood123@gmail.com> wrote: >>> On 17/07/2025 21:32, Ezekiel Newren via GitGitGadget wrote: >>>> From: Ezekiel Newren <ezekielnewren@gmail.com> >>>> >>>> A few commits ago, we added definitions for Rust primitive types, >>>> to facilitate interoperability between C and Rust. Switch a >>>> few variables to use these types. Which, for now, will >>>> require adding some casts. >>> >>> How necessary is it to change char' to 'u8' so long as the rust and C >>> sides both use a type that is the same size? Also what's the advantage >>> of using these typedefs rather than the normal C types like unit8_t ? >> Rust defines char as 32 bits. C treats char as signed 8 bits. What >> git >> really means by char* is treat everything like a byte string, and u8 >> is how raw bytes are handled in Rust. > > Right - we need to use u8 on the rust side but I'm trying to > understand why we need to change the type on the C side and why do we > need typedefs like usize and u32 on the C side when we already have > size_t and uint32_t?
Or uint8_t? Ah, eh, that is "unsigned char" so it would be redundant, I guess?