Skip to content
/ linux Public
forked from torvalds/linux

Commit

Permalink
rust: alloc: remove the borrow module (ToOwned, Cow)
Browse files Browse the repository at this point in the history
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 [1]
Link: https://doc.rust-lang.org/alloc/borrow/trait.ToOwned.html [2]
Link: https://lore.kernel.org/rust-for-linux/20221204103153.117675b1@GaryWorkstation/ [3]
Cc: Gary Guo <[email protected]>
Cc: Wedson Almeida Filho <[email protected]>
Cc: Josh Triplett <[email protected]>
Signed-off-by: Miguel Ojeda <[email protected]>
Reviewed-by: Wei Liu <[email protected]>
Reviewed-by: Finn Behrens <[email protected]>
  • Loading branch information
ojeda committed Jan 16, 2023
1 parent 5dc4c99 commit 8909a80
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 499 deletions.
1 change: 1 addition & 0 deletions rust/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ core-cfgs = \
--cfg no_fp_fmt_parse

alloc-cfgs = \
--cfg no_borrow \
--cfg no_fmt \
--cfg no_global_oom_handling \
--cfg no_macros \
Expand Down
Loading

0 comments on commit 8909a80

Please sign in to comment.