From 68d0f47d145dc783106ba5f5ea670f7aa8ee31ff Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 16 Oct 2020 21:11:37 +0200 Subject: WIP: From and Into impl for Error type Signed-off-by: Matthias Beyer --- rust/kernel/src/error.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'rust/kernel/src/error.rs') diff --git a/rust/kernel/src/error.rs b/rust/kernel/src/error.rs index 95e322e39a88..ee849e2c9ef4 100644 --- a/rust/kernel/src/error.rs +++ b/rust/kernel/src/error.rs @@ -23,6 +23,20 @@ impl Error { } } +impl From for Error { + fn from(errno: c_types::c_int) -> Self { + Error(errno) + } +} + +impl Into for Error { + type Target = c_types::c_int; + + fn into(self) -> Self::Target { + self.0 + } +} + impl From for Error { fn from(_: TryFromIntError) -> Error { Error::EINVAL -- cgit v1.2.3