Re: [PATCH v4 4/7] rust: str: make `from_bytes_with_nul_unchecked_mut` const
From: Benno Lossin
Date: Wed Jun 18 2025 - 17:16:39 EST
On Mon Jun 16, 2025 at 5:34 AM CEST, Alexandre Courbot wrote:
> This method was probably kept non-const due to the absence of the
> `const_mut_refs` feature, but it has been enabled since the introduction
> of this code (and stabilized with Rust 1.83). Thus, make it const to
> match its non-const counterpart.
>
> Signed-off-by: Alexandre Courbot <acourbot@xxxxxxxxxx>
Ah on second thought, this and the next two patches are a bit redundant,
since Tamir has a series [1] removing our `CStr` and using the one from
`core`.
If you need this *now* and can't wait for Tamir's series to land, then
we can do this and the other two changes, but othrwise I'd just use
`CStr` from `core`.
It does seem like you need `&mut CStr`, which the one in `core` doesn't
seem to provide... But our `CStr` also doesn't have `IndexMut`, so...
how are you using it? Giving it to a C API?
In that case I don't know what we should do about [1]... @Miguel?
[1]: https://lore.kernel.org/all/20250530-cstr-core-v11-0-cd9c0cbcb902@xxxxxxxxx
---
Cheers,
Benno