[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <DA2LI55W3BY8.14DMW9GGSAEY5@kernel.org>
Date: Thu, 22 May 2025 11:51:59 +0200
From: "Benno Lossin" <lossin@...nel.org>
To: "I Hsin Cheng" <richard120310@...il.com>, <ojeda@...nel.org>
Cc: <alex.gaynor@...il.com>, <boqun.feng@...il.com>, <gary@...yguo.net>,
<bjorn3_gh@...tonmail.com>, <benno.lossin@...ton.me>,
<a.hindborg@...nel.org>, <aliceryhl@...gle.com>, <tmgross@...ch.edu>,
<dakr@...nel.org>, <rust-for-linux@...r.kernel.org>,
<linux-kernel@...r.kernel.org>, <skhan@...uxfoundation.org>,
<linux-kernel-mentees@...ts.linux.dev>, <jserv@...s.ncku.edu.tw>
Subject: Re: [RFC PATCH v2] rust: list: Add examples for linked list
On Tue Mar 11, 2025 at 2:33 PM CET, I Hsin Cheng wrote:
> Add basic examples for the structure "List", also serve as the unit
> tests for basic list methods. Including the following manipulations:
> * List creation
> * List emptiness check
> * List insertion through push_front(), push_back()
> * List item removal through pop_front(), pop_back()
> * Push one list to another through push_all_back()
>
> The method "remove()" doesn't have an example here because insertion
> with push_front() or push_back() will take the ownership of the item,
> which means we can't keep any valid reference to the node we want to
> remove, unless Cursor is used. The remove example through Cursor is
> already demonstrate with 'commit 52ae96f5187c ("rust: list: make the
> cursor point between elements")' .
>
> Link: https://github.com/Rust-for-Linux/linux/issues/1121
> Signed-off-by: I Hsin Cheng <richard120310@...il.com>
> ---
> Changelog:
>
> v1 -> v2:
> - Abandon new implementation of method to create a new "ListLink"
> instance
> - Rephrase the examples' comment
> - Increase the coverity of the examples
>
> Tests was performed on ubuntu 24.04 with x86_64 architecture.
>
> $ ./tools/testing/kunit/kunit.py run --make_options LLVM=1 --arch x86_64 --kconfig_add CONFIG_RUST=y
> ...
> [21:13:11] Testing complete. Ran 615 tests: passed: 563, skipped: 52
> [21:13:11] Elapsed time: 23.020s total, 0.001s configuring, 10.985s building, 12.020s running
>
> Rust related unit tests are all passed.
>
> Best regards,
> I Hsin Cheng
> ---
> rust/kernel/list.rs | 117 ++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 117 insertions(+)
This is a nice example, so
Reviewed-by: Benno Lossin <lossin@...nel.org>
It uses `unwrap` a lot, which might confuse newcomers that that is ok in
normal code. I'm wondering if we can do something about that though...
---
Cheers,
Benno
Powered by blists - more mailing lists