rust: str: add `CStr` type
authorGary Guo <gary@garyguo.net>
Thu, 10 Nov 2022 16:41:28 +0000 (17:41 +0100)
committerMiguel Ojeda <ojeda@kernel.org>
Sun, 4 Dec 2022 00:59:15 +0000 (01:59 +0100)
commitd126d2380131dfbc880f5b5f0e3015e9bef6fa1c
tree72fd27366e7c043151f0cefd2eaa3880b47b1260
parent650ec51561fd201bcf47ce9b1d9b6fedd4bb60a6
rust: str: add `CStr` type

Add the `CStr` type, which is a borrowed string that is guaranteed
to have exactly one `NUL` byte, which is at the end.

It is used for interoperability with kernel APIs that take C strings.

Add it to the prelude too.

Co-developed-by: Alex Gaynor <alex.gaynor@gmail.com>
Signed-off-by: Alex Gaynor <alex.gaynor@gmail.com>
Co-developed-by: Milan Landaverde <milan@mdaverde.com>
Signed-off-by: Milan Landaverde <milan@mdaverde.com>
Signed-off-by: Gary Guo <gary@garyguo.net>
[Reworded, adapted for upstream and applied latest changes]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
rust/kernel/prelude.rs
rust/kernel/str.rs