Skip to content
Snippets Groups Projects
Commit 66bd7533 authored by Alice Ryhl's avatar Alice Ryhl Committed by Miguel Ojeda
Browse files

rust: str: add conversion from `CStr` to `CString`


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.

Reviewed-by: default avatarBenno Lossin <benno.lossin@proton.me>
Signed-off-by: default avatarAlice Ryhl <aliceryhl@google.com>
Reviewed-by: Martin Rodriguez Reboredo's avatarMartin Rodriguez Reboredo <yakoyoku@gmail.com>
Reviewed-by: default avatarAndreas Hindborg <a.hindborg@samsung.com>
Link: https://lore.kernel.org/r/20230503141016.683634-1-aliceryhl@google.com


Signed-off-by: default avatarMiguel Ojeda <ojeda@kernel.org>
parent 4a59081c
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment