aboutsummaryrefslogtreecommitdiffstats
path: root/rust/macros/lib.rs
diff options
context:
space:
mode:
authorDanilo Krummrich <[email protected]>2024-10-04 15:41:22 +0000
committerMiguel Ojeda <[email protected]>2024-10-15 21:10:32 +0000
commit93e602310f87b7b515b86a8f919cc0799387e5c3 (patch)
treec2d3fcb7eefb4c60d690c30ab03a40d43e1a0508 /rust/macros/lib.rs
parentrust: alloc: implement `IntoIterator` for `Vec` (diff)
downloadkernel-93e602310f87b7b515b86a8f919cc0799387e5c3.tar.gz
kernel-93e602310f87b7b515b86a8f919cc0799387e5c3.zip
rust: alloc: implement `collect` for `IntoIter`
Currently, we can't implement `FromIterator`. There are a couple of issues with this trait in the kernel, namely: - Rust's specialization feature is unstable. This prevents us to optimize for the special case where `I::IntoIter` equals `Vec`'s `IntoIter` type. - We also can't use `I::IntoIter`'s type ID either to work around this, since `FromIterator` doesn't require this type to be `'static`. - `FromIterator::from_iter` does return `Self` instead of `Result<Self, AllocError>`, hence we can't properly handle allocation failures. - Neither `Iterator::collect` nor `FromIterator::from_iter` can handle additional allocation flags. Instead, provide `IntoIter::collect`, such that we can at least convert `IntoIter` into a `Vec` again. Reviewed-by: Alice Ryhl <[email protected]> Reviewed-by: Benno Lossin <[email protected]> Signed-off-by: Danilo Krummrich <[email protected]> Link: https://lore.kernel.org/r/[email protected] [ Added newline in documentation, changed case of section to be consistent with an existing one, fixed typo. - Miguel ] Signed-off-by: Miguel Ojeda <[email protected]>
Diffstat (limited to 'rust/macros/lib.rs')
0 files changed, 0 insertions, 0 deletions