summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2020-10-16 21:11:37 +0200
committerMatthias Beyer <mail@beyermatthias.de>2020-10-16 21:11:37 +0200
commit68d0f47d145dc783106ba5f5ea670f7aa8ee31ff (patch)
treee59bb9bc129bc26ba0da2d62b9fa93a311e2f58f
parentf60edb207431c61184b6c4a562159f98c83046d1 (diff)
downloadlinux-frominto-error.tar.gz
linux-frominto-error.tar.xz
WIP: From and Into impl for Error typefrominto-error
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r--rust/kernel/src/error.rs14
1 files changed, 14 insertions, 0 deletions
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<c_types::c_int> 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<TryFromIntError> for Error {
fn from(_: TryFromIntError) -> Error {
Error::EINVAL