From 8421f2c03d6f905b58b5447a6e0469519c7f8fa6 Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Sun, 5 Jan 2020 20:44:27 +0100 Subject: Initial --- src/error.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/error.rs (limited to 'src/error.rs') diff --git a/src/error.rs b/src/error.rs new file mode 100644 index 0000000..6358bfe --- /dev/null +++ b/src/error.rs @@ -0,0 +1,23 @@ +use std::io; + +pub trait IntoIOError { + fn ioerr(self) -> io::Error; +} + +impl IntoIOError for String { + fn ioerr(self) -> io::Error { + io::Error::new(io::ErrorKind::Other, self) + } +} + +impl IntoIOError for &str { + fn ioerr(self) -> io::Error { + io::Error::new(io::ErrorKind::Other, self) + } +} + +impl IntoIOError for std::string::FromUtf8Error { + fn ioerr(self) -> io::Error { + io::Error::new(io::ErrorKind::Other, self) + } +} -- cgit v1.2.3