diff options
author | Danilo Krummrich <dakr@kernel.org> | 2025-03-08 01:49:44 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-03-13 15:01:45 +0300 |
commit | 0a798a23bbabd5544c616af3a6ef988e6c5f53c0 (patch) | |
tree | 45d98ff0fe37859fd50f3bb33c608a1e5094d6ae /scripts/generate_rust_analyzer.py | |
parent | 94091ef3d5aaaf34f429cd1ba95b40303e45494b (diff) | |
download | linux-0a798a23bbabd5544c616af3a6ef988e6c5f53c0.tar.xz |
rust: alloc: implement `collect` for `IntoIter`
commit 93e602310f87b7b515b86a8f919cc0799387e5c3 upstream.
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 <aliceryhl@google.com>
Reviewed-by: Benno Lossin <benno.lossin@proton.me>
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
Link: https://lore.kernel.org/r/20241004154149.93856-19-dakr@kernel.org
[ Added newline in documentation, changed case of section to be
consistent with an existing one, fixed typo. - Miguel ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'scripts/generate_rust_analyzer.py')
0 files changed, 0 insertions, 0 deletions