rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Benno Lossin <benno.lossin@proton.me>
To: Alice Ryhl <aliceryhl@google.com>,
	Michal Rostecki <vadorovsky@gmail.com>
Cc: "Miguel Ojeda" <ojeda@kernel.org>,
	"Alex Gaynor" <alex.gaynor@gmail.com>,
	"Wedson Almeida Filho" <wedsonaf@gmail.com>,
	"Boqun Feng" <boqun.feng@gmail.com>,
	"Gary Guo" <gary@garyguo.net>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Andreas Hindborg" <a.hindborg@samsung.com>,
	"Brendan Higgins" <brendan.higgins@linux.dev>,
	"David Gow" <davidgow@google.com>, "Rae Moar" <rmoar@google.com>,
	"FUJITA Tomonori" <fujita.tomonori@gmail.com>,
	"Trevor Gross" <tmgross@umich.edu>,
	"Nathan Chancellor" <nathan@kernel.org>,
	"Nick Desaulniers" <ndesaulniers@google.com>,
	"Bill Wendling" <morbo@google.com>,
	"Justin Stitt" <justinstitt@google.com>,
	"Martin Rodriguez Reboredo" <yakoyoku@gmail.com>,
	"Finn Behrens" <me@kloenk.dev>,
	"Manmohan Shukla" <manmshuk@gmail.com>,
	"Valentin Obst" <kernel@valentinobst.de>,
	"Yutaro Ohno" <yutaro.ono.418@gmail.com>,
	"Asahi Lina" <lina@asahilina.net>,
	"Danilo Krummrich" <dakr@redhat.com>,
	"Tiago Lam" <tiagolam@gmail.com>,
	"Charalampos Mitrodimas" <charmitro@posteo.net>,
	"Tejun Heo" <tj@kernel.org>, "Roland Xu" <mu001999@outlook.com>,
	rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com,
	netdev@vger.kernel.org, llvm@lists.linux.dev
Subject: Re: [PATCH RESEND v5] rust: str: Use `core::CStr`, remove the custom `CStr` implementation
Date: Wed, 21 Aug 2024 19:07:58 +0000	[thread overview]
Message-ID: <9f55bb2d-f963-44f6-941c-2bf9923c8beb@proton.me> (raw)
In-Reply-To: <CAH5fLghOFYxwCOGrk8NYX0V9rgrJJ70YOa+dY1O0pbNB-CoK=w@mail.gmail.com>

On 21.08.24 14:08, Alice Ryhl wrote:
> On Mon, Aug 19, 2024 at 5:39 PM Michal Rostecki <vadorovsky@gmail.com> wrote:
>>
>> From: Michal Rostecki <vadorovsky@gmail.com>
>>
>> `CStr` became a part of `core` library in Rust 1.75. This change replaces
>> the custom `CStr` implementation with the one from `core`.
>>
>> `core::CStr` behaves generally the same as the removed implementation,
>> with the following differences:
>>
>> - It does not implement `Display`.
>> - It does not provide `from_bytes_with_nul_unchecked_mut` method.
>> - It has `as_ptr()` method instead of `as_char_ptr()`, which also returns
>>   `*const c_char`.
>>
>> The first two differences are handled by providing the `CStrExt` trait,
>> with `display()` and `from_bytes_with_nul_unchecked_mut()` methods.
>> `display()` returns a `CStrDisplay` wrapper, with a custom `Display`
>> implementation.
>>
>> `DerefMut` implementation for `CString` is removed here, as it's not
>> being used anywhere.
>>
>> Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
> 
> A few comments:
> 
> * I would probably add CStrExt to the kernel prelude.
> * I would probably remove `from_bytes_with_nul_unchecked_mut` and keep
> `DerefMut for CString` instead of the other way around.
> * Perhaps we should remove the `c_str!` macro and use c"" instead?

Read [1], it is needed, because there is no `c_stringify!` macro.

[1]: https://lore.kernel.org/rust-for-linux/52676577-372c-4a7f-aace-4cf100f93bfb@gmail.com/

---
Cheers,
Benno


  parent reply	other threads:[~2024-08-21 19:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-19 15:36 [PATCH RESEND v5] rust: str: Use `core::CStr`, remove the custom `CStr` implementation Michal Rostecki
2024-08-19 15:41 ` Michal Rostecki
2024-08-24  7:24   ` Trevor Gross
2024-08-21 12:08 ` Alice Ryhl
2024-08-21 13:47   ` Alice Ryhl
2024-08-21 19:07   ` Benno Lossin [this message]
2024-08-24  7:22 ` Trevor Gross

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=9f55bb2d-f963-44f6-941c-2bf9923c8beb@proton.me \
    --to=benno.lossin@proton.me \
    --cc=a.hindborg@samsung.com \
    --cc=alex.gaynor@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=brendan.higgins@linux.dev \
    --cc=charmitro@posteo.net \
    --cc=dakr@redhat.com \
    --cc=davidgow@google.com \
    --cc=fujita.tomonori@gmail.com \
    --cc=gary@garyguo.net \
    --cc=justinstitt@google.com \
    --cc=kernel@valentinobst.de \
    --cc=kunit-dev@googlegroups.com \
    --cc=lina@asahilina.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=manmshuk@gmail.com \
    --cc=me@kloenk.dev \
    --cc=morbo@google.com \
    --cc=mu001999@outlook.com \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=ojeda@kernel.org \
    --cc=rmoar@google.com \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tiagolam@gmail.com \
    --cc=tj@kernel.org \
    --cc=tmgross@umich.edu \
    --cc=vadorovsky@gmail.com \
    --cc=wedsonaf@gmail.com \
    --cc=yakoyoku@gmail.com \
    --cc=yutaro.ono.418@gmail.com \
    /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;
as well as URLs for NNTP newsgroup(s).