summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2019-10-26 16:33:05 +0200
committerMatthias Beyer <mail@beyermatthias.de>2019-10-26 18:16:37 +0200
commit106be5746d7b264fba8056d9e382f8594334e346 (patch)
tree33d56976e9ec443bf86d0dc6a1d6ef41ff8fdbd2
parent434f84c80dc528cdefaf7b0e305e51ca039c3a4d (diff)
Revert "Add extension traits for handling Result<Option<T>, E> conversion"
This reverts commit d810b63886f4006d01bca894982bbc867616f37c. As resiter v0.4.0 does provide this extension now, we don't need it in the codebase anymore.
-rw-r--r--lib/core/libimagerror/src/iter.rs46
-rw-r--r--lib/core/libimagerror/src/lib.rs1
-rw-r--r--lib/core/libimagerror/src/result.rs38
3 files changed, 0 insertions, 85 deletions
diff --git a/lib/core/libimagerror/src/iter.rs b/lib/core/libimagerror/src/iter.rs
index 1e7dbff9..5a288321 100644
--- a/lib/core/libimagerror/src/iter.rs
+++ b/lib/core/libimagerror/src/iter.rs
@@ -128,49 +128,3 @@ impl<I, T> TraceIterator<T> for I where
I: Iterator<Item = Result<T, Error>>
{}
-
-/// Extension trait for doing
-///
-/// ```ignore
-/// Iterator<Item = Result<Option<T>, E>> -> Iterator<Item = Result<T, E>>
-/// ```
-///
-pub trait IterInnerOkOrElse<T, E, F>
- where T: Sized,
- E: Sized,
- Self: Iterator<Item = Result<Option<T>, E>> + Sized,
- F: Fn() -> E,
-{
- fn map_inner_ok_or_else(self, f: F) -> IterInnerOkOrElseImpl<Self, T, E, F>;
-}
-
-pub struct IterInnerOkOrElseImpl<I, T, E, F>(I, F)
- where I: Iterator<Item = Result<Option<T>, E>> + Sized,
- T: Sized,
- E: Sized,
- F: Fn() -> E;
-
-impl<I, T, E, F> IterInnerOkOrElse<T, E, F> for I
- where I: Iterator<Item = Result<Option<T>, E>> + Sized,
- T: Sized,
- E: Sized,
- F: Fn() -> E,
-{
- fn map_inner_ok_or_else(self, f: F) -> IterInnerOkOrElseImpl<I, T, E, F> {
- IterInnerOkOrElseImpl(self, f)
- }
-}
-
-impl<I, T, E, F> Iterator for IterInnerOkOrElseImpl<I, T, E, F>
- where I: Iterator<Item = Result<Option<T>, E>> + Sized,
- T: Sized,
- E: Sized,
- F: Fn() -> E,
-{
- type Item = Result<T, E>;
-
- fn next(&mut self) -> Option<Self::Item> {
- self.0.next().map(|e| e.and_then(|opt| opt.ok_or_else(|| (self.1)())))
- }
-}
-
diff --git a/lib/core/libimagerror/src/lib.rs b/lib/core/libimagerror/src/lib.rs
index 9b5e8407..22391142 100644
--- a/lib/core/libimagerror/src/lib.rs
+++ b/lib/core/libimagerror/src/lib.rs
@@ -44,7 +44,6 @@ pub mod errors;
pub mod exit;
pub mod io;
pub mod iter;
-pub mod result;
pub mod str;
pub mod trace;
diff --git a/lib/core/libimagerror/src/result.rs b/lib/core/libimagerror/src/result.rs
deleted file mode 100644
index 0dcb5333..00000000
--- a/lib/core/libimagerror/src/result.rs
+++ /dev/null
@@ -1,38 +0,0 @@
-//
-// imag - the personal information management suite for the commandline
-// Copyright (C) 2015-2019 the imag contributors
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; version
-// 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-//
-
-/// Extension trait for doing `Result<Option<T>, E> -> Result<T, E>`
-pub trait ResultOptionExt<T, E, F>
- where T: Sized,
- E: Sized,
- F: FnOnce() -> E
-{
- fn inner_ok_or_else(self, f: F) -> Result<T, E>;
-}
-
-impl<T, E, F> ResultOptionExt<T, E, F> for Result<Option<T>, E>
- where T: Sized,
- E: Sized,
- F: FnOnce() -> E
-{
- fn inner_ok_or_else(self, f: F) -> Result<T, E> {
- self.and_then(|opt| opt.ok_or_else(f))
- }
-}
-