lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID:
 <CH3PR12MB90797749F5A623D292671E689724A@CH3PR12MB9079.namprd12.prod.outlook.com>
Date: Wed, 30 Jul 2025 16:27:20 +0800
From: Kunwu Chan <kunwu.chan@...mail.com>
To: Hui Zhu <hui.zhu@...ux.dev>, Danilo Krummrich <dakr@...nel.org>,
 Lorenzo Stoakes <lorenzo.stoakes@...cle.com>,
 Vlastimil Babka <vbabka@...e.cz>, "Liam R . Howlett"
 <Liam.Howlett@...cle.com>, Uladzislau Rezki <urezki@...il.com>,
 Miguel Ojeda <ojeda@...nel.org>, Alex Gaynor <alex.gaynor@...il.com>,
 Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>,
 bjorn3_gh@...tonmail.com, Benno Lossin <lossin@...nel.org>,
 Andreas Hindborg <a.hindborg@...nel.org>, Alice Ryhl <aliceryhl@...gle.com>,
 Trevor Gross <tmgross@...ch.edu>, rust-for-linux@...r.kernel.org,
 linux-kernel@...r.kernel.org, akpm@...ux-foundation.org,
 vitaly.wool@...sulko.se
Cc: Hui Zhu <zhuhui@...inos.cn>, Geliang Tang <geliang@...nel.org>
Subject: Re: [PATCH v6 2/2] rust: alloc: kvec: add doc example for as_slice
 method

On 2025/7/30 11:35, Hui Zhu wrote:
> From: Hui Zhu <zhuhui@...inos.cn>
>
> Add a practical usage example to the documentation of KVec::as_slice()
> showing how to:
> Create a new KVec.
> Push elements into it.
> Convert to a slice via as_slice().
>
> Co-developed-by: Geliang Tang <geliang@...nel.org>
> Signed-off-by: Geliang Tang <geliang@...nel.org>
> Signed-off-by: Hui Zhu <zhuhui@...inos.cn>
> ---
>   rust/kernel/alloc/kvec.rs | 10 ++++++++++
>   1 file changed, 10 insertions(+)
>
> diff --git a/rust/kernel/alloc/kvec.rs b/rust/kernel/alloc/kvec.rs
> index 92d0ed3f302e..f57e08c64929 100644
> --- a/rust/kernel/alloc/kvec.rs
> +++ b/rust/kernel/alloc/kvec.rs
> @@ -224,6 +224,16 @@ unsafe fn dec_len(&mut self, count: usize) -> &mut [T] {
>       }
>   
>       /// Returns a slice of the entire vector.
> +    ///
> +    /// # Examples
> +    ///
> +    /// ```
> +    /// let mut v = KVec::new();
> +    /// v.push(1, GFP_KERNEL)?;
> +    /// v.push(2, GFP_KERNEL)?;
> +    /// assert_eq!(v.as_slice(), &[1, 2]);
> +    /// # Ok::<(), Error>(())
> +    /// ```
>       #[inline]
>       pub fn as_slice(&self) -> &[T] {
>           self

LGTM.

Reviewed-by: Kunwu Chan <chentao@...inos.cn>

-- 
Thanks,
   Kunwu.Chan(Tao.Chan)


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ