Commit 597ebe7c authored by Tamir Duberstein's avatar Tamir Duberstein Committed by Matthew Maurer
Browse files

FROMGIT: rust: alloc: refactor `Vec::truncate` using `dec_len`



Use `checked_sub` to satisfy the safety requirements of `dec_len` and
replace nearly the whole body of `truncate` with a call to `dec_len`.

Reviewed-by: default avatarAndrew Ballance <andrewjballance@gmail.com>
Reviewed-by: default avatarAlice Ryhl <aliceryhl@google.com>
Signed-off-by: default avatarTamir Duberstein <tamird@gmail.com>
Link: https://lore.kernel.org/r/20250416-vec-set-len-v4-3-112b222604cd@gmail.com


[ Remove #[expect(unused)] from dec_len(). - Danilo ]
Signed-off-by: default avatarDanilo Krummrich <dakr@kernel.org>

Bug: 414994413
(cherry picked from commit 1b04b466
 https://github.com/Rust-for-Linux/linux.git

 alloc-next)
Change-Id: I7b1137306936289037bd315d32bb4ca893d38419
Signed-off-by: default avatarAlice Ryhl <aliceryhl@google.com>
parent 8a1546ee
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment