From 4a59081c09cbfe17505baf3db50ebb9b97290bae Mon Sep 17 00:00:00 2001 From: Alice Ryhl Date: Tue, 2 May 2023 12:40:15 +0000 Subject: rust: error: allow specifying error type on `Result` Currently, if the `kernel::error::Result` type is in scope (which is often is, since it's in the kernel's prelude), you cannot write `Result` when you want to use a different error type than `kernel::error::Error`. To solve this we change the error type from being hard-coded to just being a default generic parameter. This still lets you write `Result` when you just want to use the `Error` error type, but also lets you write `Result` when necessary. Signed-off-by: Alice Ryhl Reviewed-by: Benno Lossin Reviewed-by: Asahi Lina Reviewed-by: Andreas Hindborg Reviewed-by: Gary Guo Link: https://lore.kernel.org/r/20230502124015.356001-1-aliceryhl@google.com Signed-off-by: Miguel Ojeda --- rust/kernel/error.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'rust') diff --git a/rust/kernel/error.rs b/rust/kernel/error.rs index 5f4114b30b94..01dd4d2f63d2 100644 --- a/rust/kernel/error.rs +++ b/rust/kernel/error.rs @@ -177,7 +177,7 @@ impl From for Error { /// Note that even if a function does not return anything when it succeeds, /// it should still be modeled as returning a `Result` rather than /// just an [`Error`]. -pub type Result = core::result::Result; +pub type Result = core::result::Result; /// Converts an integer as returned by a C kernel function to an error if it's negative, and /// `Ok(())` otherwise. -- cgit v1.2.3