diff options
author | I Hsin Cheng <richard120310@gmail.com> | 2025-03-11 21:33:57 +0800 |
---|---|---|
committer | Miguel Ojeda <ojeda@kernel.org> | 2025-05-22 12:00:52 +0200 |
commit | 195746046c256ce5324772394c886ba798859fca (patch) | |
tree | 9606febf7800ba48113c66c6b4bd97a6a047bfea /scripts/generate_rust_analyzer.py | |
parent | 28669b2f37e9b7e98b62d0be2e10a5bf31c2b16f (diff) |
rust: list: Add examples for linked list
Add basic examples for the structure "List", which also serve as unit
tests for basic list methods. It includes 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 demonstrated 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@gmail.com>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Reviewed-by: Benno Lossin <lossin@kernel.org>
Link: https://lore.kernel.org/r/20250311133357.90322-1-richard120310@gmail.com
[ Removed prelude import and spurious newlines. Formatted comments
with the usual style. Reworded slightly. - Miguel ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Diffstat (limited to 'scripts/generate_rust_analyzer.py')
0 files changed, 0 insertions, 0 deletions