mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Alexandre Courbot" <acourbot@nvidia.com>
To: "Miguel Ojeda" <miguel.ojeda.sandonis@gmail.com>
Cc: "Danilo Krummrich" <dakr@kernel.org>,
	"Miguel Ojeda" <ojeda@kernel.org>,
	"Alex Gaynor" <alex.gaynor@gmail.com>,
	"Boqun Feng" <boqun.feng@gmail.com>,
	"Gary Guo" <gary@garyguo.net>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <lossin@kernel.org>,
	"Andreas Hindborg" <a.hindborg@kernel.org>,
	"Alice Ryhl" <aliceryhl@google.com>,
	"Trevor Gross" <tmgross@umich.edu>,
	rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 4/4] rust: str: implement `Borrow` and `BorrowMut` for `CString`
Date: Sun, 15 Jun 2025 22:48:05 +0900	[thread overview]
Message-ID: <DAN5JZIZEIIR.3DJEY70B1TZJT@nvidia.com> (raw)
In-Reply-To: <CANiq72kmN1iK=AD0yzj5TyMGJowaFzGMZjEXfUM3TCSRJkYuNQ@mail.gmail.com>

On Sun Jun 15, 2025 at 10:15 PM JST, Miguel Ojeda wrote:
> On Sun, Jun 15, 2025 at 2:37 PM Alexandre Courbot <acourbot@nvidia.com> wrote:
>>
>> +/// // Borrowed from `str_data`.
>> +/// let foo_borrowed = Foo(unsafe { CStr::from_bytes_with_nul_unchecked_mut(&mut str_data) });
>
> We will need a `// SAFETY:` comment -- Clippy should complain.

I thought I could get away with it since it is in a test, and clippy
does not seem to complain about it, but...

>
> Or to add a safe `from_bytes_with_nul_mut`, I guess.

... as penance (and for symmetry with `from_bytes_with_nul`), let me
implement that so we don't need a safety block at all. :)


  reply	other threads:[~2025-06-15 13:48 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-15 12:37 [PATCH v3 0/4] rust: a few common Borrow/BorrowMut implementations Alexandre Courbot
2025-06-15 12:37 ` [PATCH v3 1/4] rust: alloc: implement `Borrow` and `BorrowMut` for `Vec` Alexandre Courbot
2025-06-15 12:37 ` [PATCH v3 2/4] rust: sync: implement `Borrow` and `BorrowMut` for `Arc` types Alexandre Courbot
2025-06-15 12:37 ` [PATCH v3 3/4] rust: alloc: implement `Borrow` and `BorrowMut` for `KBox` Alexandre Courbot
2025-06-15 12:37 ` [PATCH v3 4/4] rust: str: implement `Borrow` and `BorrowMut` for `CString` Alexandre Courbot
2025-06-15 13:15   ` Miguel Ojeda
2025-06-15 13:48     ` Alexandre Courbot [this message]
2025-06-15 13:57       ` Miguel Ojeda
2025-06-15 14:08         ` Alexandre Courbot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DAN5JZIZEIIR.3DJEY70B1TZJT@nvidia.com \
    --to=acourbot@nvidia.com \
    --cc=a.hindborg@kernel.org \
    --cc=alex.gaynor@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=dakr@kernel.org \
    --cc=gary@garyguo.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=miguel.ojeda.sandonis@gmail.com \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tmgross@umich.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®