Re: [PATCH] rust: uaccess: avoid unsafe unwrap_unchecked() in strcpy_into_buf()

From: Miguel Ojeda

Date: Sun Oct 11 2026 - 04:42:31 EST


On Sat, Oct 10, 2026 at 4:40 AM Alexandre Courbot <acourbot@xxxxxxxxxx> wrote:
>
> On Fri Oct 9, 2026 at 11:11 PM JST, Gary Guo wrote:
> >
> > A `NonEmptySlice<T>` which is `[T]` but `first`/`last` can just not return
> > `Option`?
>
> I looked it up hoping it already existed. :)
>
> That would definitely be an elegant way to solve this issue (and IMHO
> should eventually become part of the standard library). This example is
> actually a great illustration of the panic/unsafe/result dilemma we
> discussed during Kangrejos (and yes, I'll follow-up with a proposal for
> guidelines soon, sorry about the delay).
>
> Until we have `NonEmptySlice`, I'd say the current unsafe or having a
> panic are morally equivalent, so I don't see a strong justification for
> this patch.

Sounds like something to explore; filled:
https://github.com/Rust-for-Linux/linux/issues/1262

I can convert it to a "good first issue" if you guys prefer.

Cheers,
Miguel