linux/rust/alloc
Miguel Ojeda 318c3cc8e1 rust: alloc: vec: Add some try_* methods we need
Add some missing fallible methods that we need.

They are all marked as:

    #[stable(feature = "kernel", since = "1.0.0")]

for easy identification.

Lina: Extracted from commit 487d7578bd03 ("rust: alloc: add some `try_*`
methods we need") in rust-for-linux/rust.

Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Signed-off-by: Asahi Lina <lina@asahilina.net>
Link: https://github.com/Rust-for-Linux/linux/commit/487d7578bd03
Link: https://lore.kernel.org/r/20230224-rust-vec-v1-4-733b5b5a57c5@asahilina.net
[ Match the non-fallible methods from version 1.62.0, since those
  in commit 487d7578bd03 were written for 1.54.0-beta.1. ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2023-04-10 23:55:43 +02:00
..
collections rust: adapt alloc crate to the kernel 2022-09-28 08:57:01 +02:00
vec rust: alloc: vec: Add some try_* methods we need 2023-04-10 23:55:43 +02:00
alloc.rs rust: adapt alloc crate to the kernel 2022-09-28 08:57:01 +02:00
boxed.rs rust: adapt alloc crate to the kernel 2022-09-28 08:57:01 +02:00
lib.rs rust: alloc: remove the borrow module (ToOwned, Cow) 2023-01-16 21:03:49 +01:00
raw_vec.rs rust: alloc: add Vec::try_with_capacity{,_in}() constructors 2022-12-04 01:59:15 +01:00
README.md rust: adapt alloc crate to the kernel 2022-09-28 08:57:01 +02:00
slice.rs rust: adapt alloc crate to the kernel 2022-09-28 08:57:01 +02:00

alloc

These source files come from the Rust standard library, hosted in the https://github.com/rust-lang/rust repository, licensed under "Apache-2.0 OR MIT" and adapted for kernel use. For copyright details, see https://github.com/rust-lang/rust/blob/master/COPYRIGHT.

Please note that these files should be kept as close as possible to upstream. In general, only additions should be performed (e.g. new methods). Eventually, changes should make it into upstream so that, at some point, this fork can be dropped from the kernel tree.

Rationale

On one hand, kernel folks wanted to keep alloc in-tree to have more freedom in both workflow and actual features if actually needed (e.g. receiver types if we ended up using them), which is reasonable.

On the other hand, Rust folks wanted to keep alloc as close as upstream as possible and avoid as much divergence as possible, which is also reasonable.

We agreed on a middle-ground: we would keep a subset of alloc in-tree that would be as small and as close as possible to upstream. Then, upstream can start adding the functions that we add to alloc etc., until we reach a point where the kernel already knows exactly what it needs in alloc and all the new methods are merged into upstream, so that we can drop alloc from the kernel tree and go back to using the upstream one.

By doing this, the kernel can go a bit faster now, and Rust can slowly incorporate and discuss the changes as needed.