Re: [PATCH v2] rust: str: add conversion from `CStr` to `CString`
From: Alice Ryhl
Date: Mon May 08 2023 - 16:29:13 EST
On 5/8/23 13:41, Gary Guo wrote:
On Wed, 3 May 2023 14:10:16 +0000
Alice Ryhl <aliceryhl@xxxxxxxxxx> 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.