Rust for Linux List
 help / color / mirror / Atom feed
* [RFC PATCH v1 0/2] Add NonEmptySlice
@ 2026-10-11 19:15 Francis Laniel
  2026-10-11 19:15 ` [RFC PATCH v1 1/2] rust: add NonEmptySlice Francis Laniel
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Francis Laniel @ 2026-10-11 19:15 UTC (permalink / raw)
  To: Miguel Ojeda, Boqun Feng, Gary Guo, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
	Danilo Krummrich, Daniel Almeida, Tamir Duberstein,
	Alexandre Courbot, Onur Özkan
  Cc: Thorsten Blum, Francis Laniel, rust-for-linux

Hi,

Following the discussion in:
https://lore.kernel.org/rust-for-linux/DM0D9TERQAM3.2Y3HV6P68E2N8@garyguo.net/
I wrote some code to add a new NonEmptySlice type which ensures the underlying
type is no empty. This way, caller can use first()/last() without relying on
unsafe.

For now, only new_mut() and last_mut() are used in uaccess.rs. Please let me
know if I need to remove the other functions from slice.rs to only what is
needed.

Francis Laniel (2):
  rust: add NonEmptySlice
  rust: uaccess: Use slice::NonEmptySlice in strcpy_into_buf()

 rust/kernel/lib.rs     |  1 +
 rust/kernel/slice.rs   | 76 ++++++++++++++++++++++++++++++++++++++++++
 rust/kernel/uaccess.rs | 11 +++---
 3 files changed, 81 insertions(+), 7 deletions(-)
 create mode 100644 rust/kernel/slice.rs

Best regards,
-- 
2.47.3


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-10-12 15:11 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-11 19:15 [RFC PATCH v1 0/2] Add NonEmptySlice Francis Laniel
2026-10-11 19:15 ` [RFC PATCH v1 1/2] rust: add NonEmptySlice Francis Laniel
2026-10-12 14:36   ` Alexandre Courbot
2026-10-12 15:11     ` Francis Laniel
2026-10-11 19:15 ` [RFC PATCH v1 2/2] rust: uaccess: Use slice::NonEmptySlice in strcpy_into_buf() Francis Laniel
2026-10-12  0:21 ` [RFC PATCH v1 0/2] Add NonEmptySlice Alexandre Courbot
2026-10-12  7:11   ` Francis Laniel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox