Commit 7d8dee46 authored by Miguel Ojeda's avatar Miguel Ojeda
Browse files

rust: uaccess: take advantage of the prelude and `Result`'s defaults



The `kernel` prelude brings `Result` and the error codes; and the prelude
itself is already available in the examples automatically.

In addition, `Result` already defaults to `T = ()`.

Thus simplify.

Reviewed-by: default avatarAlice Ryhl <aliceryhl@google.com>
Link: https://lore.kernel.org/r/20250429151445.438977-1-ojeda@kernel.org


Signed-off-by: default avatarMiguel Ojeda <ojeda@kernel.org>
parent 0fa5f8c8
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -46,10 +46,9 @@
///
/// ```no_run
/// use kernel::ffi::c_void;
/// use kernel::error::Result;
/// use kernel::uaccess::{UserPtr, UserSlice};
///
/// fn bytes_add_one(uptr: UserPtr, len: usize) -> Result<()> {
/// fn bytes_add_one(uptr: UserPtr, len: usize) -> Result {
///     let (read, mut write) = UserSlice::new(uptr, len).reader_writer();
///
///     let mut buf = KVec::new();
@@ -68,7 +67,6 @@
///
/// ```no_run
/// use kernel::ffi::c_void;
/// use kernel::error::{code::EINVAL, Result};
/// use kernel::uaccess::{UserPtr, UserSlice};
///
/// /// Returns whether the data in this region is valid.