rust: alloc: remove the `borrow` module (`ToOwned`, `Cow`)
authorMiguel Ojeda <ojeda@kernel.org>
Tue, 6 Dec 2022 01:05:19 +0000 (02:05 +0100)
committerMiguel Ojeda <ojeda@kernel.org>
Mon, 16 Jan 2023 20:03:49 +0000 (21:03 +0100)
commit8909a80e3f684fb274a171489c16e8f10c482e83
treeaa07f495d0a8439d6a3a5fbef53587606f2ff052
parent5dc4c995db9eb45f6373a956eb1f69460e69e6d4
rust: alloc: remove the `borrow` module (`ToOwned`, `Cow`)

The `Cow` type [1] requires that its generic parameter type implements
the `ToOwned` trait [2], which provides a method to create owned data
from borrowed data, usually by cloning.

However, it is infallible, and thus in most cases it is not useful for
the kernel. [3]

Therefore, introduce `cfg(no_borrow)` to remove the `borrow` module
(which contains `ToOwned` and `Cow`) from `alloc`.

Link: https://doc.rust-lang.org/alloc/borrow/enum.Cow.html
Link: https://doc.rust-lang.org/alloc/borrow/trait.ToOwned.html
Link: https://lore.kernel.org/rust-for-linux/20221204103153.117675b1@GaryWorkstation/
Cc: Gary Guo <gary@garyguo.net>
Cc: Wedson Almeida Filho <wedsonaf@gmail.com>
Cc: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Reviewed-by: Wei Liu <wei.liu@kernel.org>
Reviewed-by: Finn Behrens <fin@nyantec.com>
rust/Makefile
rust/alloc/borrow.rs [deleted file]
rust/alloc/lib.rs
rust/alloc/vec/mod.rs