Thank you for your contribution! Sashiko AI review found 1 potential issue(s) 
to consider:
- [Low] Small abstraction functions are missing the `#[inline]` attribute.
--

commit 04be610d7cb2829e10f7bdcdb68a4d11695975ca
Author: Eliot Courtney <[email protected]>

rust: alloc: add ArrayVec

Add a fixed capacity vector backed by an uninitialized array. The ArrayVec
is initializable with a closure to avoid stack construction. It provides
a way to avoid heap allocations for small but varying size arrays stored
on the stack.

> diff --git a/rust/kernel/alloc/arrayvec.rs b/rust/kernel/alloc/arrayvec.rs
> new file mode 100644
> index 0000000000000..4172a982e4775
> --- /dev/null
> +++ b/rust/kernel/alloc/arrayvec.rs
[ ... ]
> +    /// Appends an element to the back of the [`ArrayVec`].
> +    ///
> +    /// Fails when the [`ArrayVec`] is full, handing the element back in 
> [`PushError`].
> +    pub fn push(&mut self, v: T) -> Result<(), PushError<T>> {

[Severity: Low]
Should ArrayVec::push in rust/kernel/alloc/arrayvec.rs include an #[inline]
attribute?

> +        self.try_push_init(v)
> +            .map_err(|PushInitError::Full(v)| PushError(v))
> +    }
> +
> +    /// Appends an element to the back of the [`ArrayVec`] by initializing 
> it in place.
> +    ///
> +    /// Fails with [`FullError`] when the [`ArrayVec`] is full.
> +    pub fn push_init(&mut self, init: impl Init<T>) -> Result<(), FullError> 
> {

[Severity: Low]
Would it be appropriate to add #[inline] to ArrayVec::push_init as well,
given that it purely forwards to try_push_init?

> +        self.try_push_init(init)
> +            .map_err(|PushInitError::Full(_)| FullError)
> +    }
[ ... ]
> +    /// Returns a slice of `MaybeUninit<T>` for the remaining spare capacity 
> of the [`ArrayVec`].
> +    fn spare_capacity_mut(&mut self) -> &mut [MaybeUninit<T>] {

[Severity: Low]
Is the short helper function ArrayVec::spare_capacity_mut missing an #[inline]
attribute?

> +        // PANIC: `len` never exceeds `N` by the type invariants.
> +        &mut self.data[self.len..]
> +    }

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=3

Reply via email to