From: Andreas Hindborg <nmi@metaspace.dk>
To: Alice Ryhl <alice@ryhl.io>
Cc: "Gary Guo" <gary@garyguo.net>, "Miguel Ojeda" <ojeda@kernel.org>,
"Wedson Almeida Filho" <wedsonaf@gmail.com>,
"Alex Gaynor" <alex.gaynor@gmail.com>,
"Boqun Feng" <boqun.feng@gmail.com>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <benno.lossin@proton.me>,
"Martin Rodriguez Reboredo" <yakoyoku@gmail.com>,
rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org,
patches@lists.linux.dev
Subject: Re: [PATCH v2] rust: str: add conversion from `CStr` to `CString`
Date: Mon, 15 May 2023 20:12:57 +0200 [thread overview]
Message-ID: <871qjhe9xh.fsf@metaspace.dk> (raw)
In-Reply-To: <bb3bfbfb-0761-23b2-24e9-e5b4cb3ffac6@ryhl.io>
Alice Ryhl <alice@ryhl.io> writes:
> On 5/8/23 13:41, Gary Guo wrote:
>> On Wed, 3 May 2023 14:10:16 +0000
>> Alice Ryhl <aliceryhl@google.com> wrote:
>>
>>> These methods can be used to copy the data in a temporary c string into
>>> a separate allocation, so that it can be accessed later even if the
>>> original is deallocated.
>>>
>>> The API in this change mirrors the standard library API for the `&str`
>>> and `String` types. The `ToOwned` trait is not implemented because it
>>> assumes that allocations are infallible.
>> How about add a `TryToOwned` trait to the kernel crate and implement
>> that trait for `CStr` instead?
>
> Eh, I don't think it's worth it. It doesn't give anything new to the CStr api,
> and I think it's rather unlikely that someone will actually need to be generic
> over such a trait any time soon.
It is just as valid as having `From<&str>` and `ToOwned<&str>`. While it
does not add anything in terms of function, it carries intention. I
think we should consider adding it at some point.
BR Andreas
next prev parent reply other threads:[~2023-05-15 18:17 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-03 14:10 [PATCH v2] rust: str: add conversion from `CStr` to `CString` Alice Ryhl
2023-05-03 19:01 ` Martin Rodriguez Reboredo
2023-05-08 11:41 ` Gary Guo
2023-05-08 20:29 ` Alice Ryhl
2023-05-15 18:12 ` Andreas Hindborg [this message]
2023-05-16 11:12 ` Alice Ryhl
2023-05-17 18:09 ` Gary Guo
2023-05-15 18:36 ` Andreas Hindborg
2023-05-31 17:09 ` Miguel Ojeda
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=871qjhe9xh.fsf@metaspace.dk \
--to=nmi@metaspace.dk \
--cc=alex.gaynor@gmail.com \
--cc=alice@ryhl.io \
--cc=benno.lossin@proton.me \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=gary@garyguo.net \
--cc=linux-kernel@vger.kernel.org \
--cc=ojeda@kernel.org \
--cc=patches@lists.linux.dev \
--cc=rust-for-linux@vger.kernel.org \
--cc=wedsonaf@gmail.com \
--cc=yakoyoku@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.