Merge branch 'resiter-update' into master
Update the resiter dependency, so we can remove our implementation of the `IterInnerOkOrElse` extension trait. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This commit is contained in:
commit
b6facfff6b
22 changed files with 20 additions and 103 deletions
|
@ -24,7 +24,7 @@ log = "0.4.6"
|
|||
toml = "0.5.1"
|
||||
toml-query = "0.9.2"
|
||||
failure = "0.1.5"
|
||||
resiter = "0.3.0"
|
||||
resiter = "0.4.0"
|
||||
|
||||
libimagstore = { version = "0.10.0", path = "../../../lib/core/libimagstore" }
|
||||
libimagrt = { version = "0.10.0", path = "../../../lib/core/libimagrt" }
|
||||
|
|
|
@ -53,7 +53,6 @@ use clap::App;
|
|||
use libimagerror::trace::MapErrTrace;
|
||||
use libimagrt::runtime::Runtime;
|
||||
use libimagrt::application::ImagApplication;
|
||||
use libimagerror::iter::IterInnerOkOrElse;
|
||||
|
||||
mod ui;
|
||||
|
||||
|
@ -62,6 +61,7 @@ use std::io::Write;
|
|||
use failure::err_msg;
|
||||
use failure::Error;
|
||||
use resiter::AndThen;
|
||||
use resiter::IterInnerOkOrElse;
|
||||
|
||||
use libimagentrycategory::store::CategoryStore;
|
||||
use libimagstore::iter::get::StoreIdGetIteratorExtension;
|
||||
|
|
|
@ -19,7 +19,7 @@ toml = "0.5.1"
|
|||
toml-query = "0.9.2"
|
||||
indicatif = "0.12.0"
|
||||
failure = "0.1.5"
|
||||
resiter = "0.3.0"
|
||||
resiter = "0.4.0"
|
||||
|
||||
libimagstore = { version = "0.10.0", path = "../../../lib/core/libimagstore" }
|
||||
libimagrt = { version = "0.10.0", path = "../../../lib/core/libimagrt" }
|
||||
|
|
|
@ -54,7 +54,6 @@ use libimagrt::application::ImagApplication;
|
|||
use libimagstore::store::FileLockEntry;
|
||||
use libimagstore::storeid::StoreId;
|
||||
use libimagentrylink::linkable::Linkable;
|
||||
use libimagerror::iter::IterInnerOkOrElse;
|
||||
|
||||
use toml::Value;
|
||||
use toml_query::read::TomlValueReadExt;
|
||||
|
@ -63,6 +62,7 @@ use failure::Fallible as Result;
|
|||
use failure::err_msg;
|
||||
use clap::App;
|
||||
use resiter::AndThen;
|
||||
use resiter::IterInnerOkOrElse;
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ version = "3.0.0"
|
|||
toml = "0.5.1"
|
||||
toml-query = "0.9.2"
|
||||
failure = "0.1.5"
|
||||
resiter = "0.3.0"
|
||||
resiter = "0.4.0"
|
||||
|
||||
libimagstore = { version = "0.10.0", path = "../../../lib/core/libimagstore" }
|
||||
libimagrt = { version = "0.10.0", path = "../../../lib/core/libimagrt" }
|
||||
|
|
|
@ -50,11 +50,11 @@ use libimagentryedit::edit::EditHeader;
|
|||
use libimagrt::runtime::Runtime;
|
||||
use libimagrt::application::ImagApplication;
|
||||
use libimagstore::iter::get::StoreIdGetIteratorExtension;
|
||||
use libimagerror::iter::IterInnerOkOrElse;
|
||||
|
||||
use failure::Fallible as Result;
|
||||
use failure::err_msg;
|
||||
use resiter::AndThen;
|
||||
use resiter::IterInnerOkOrElse;
|
||||
use clap::App;
|
||||
|
||||
mod ui;
|
||||
|
|
|
@ -23,7 +23,7 @@ maintenance = { status = "actively-developed" }
|
|||
log = "0.4.6"
|
||||
regex = "1.1.7"
|
||||
failure = "0.1.5"
|
||||
resiter = "0.3.0"
|
||||
resiter = "0.4.0"
|
||||
|
||||
libimagstore = { version = "0.10.0", path = "../../../lib/core/libimagstore" }
|
||||
libimagrt = { version = "0.10.0", path = "../../../lib/core/libimagrt" }
|
||||
|
|
|
@ -52,11 +52,11 @@ use failure::Error;
|
|||
use failure::Fallible as Result;
|
||||
use failure::err_msg;
|
||||
use resiter::AndThen;
|
||||
use resiter::IterInnerOkOrElse;
|
||||
|
||||
use libimagrt::runtime::Runtime;
|
||||
use libimagrt::application::ImagApplication;
|
||||
use libimagstore::store::Entry;
|
||||
use libimagerror::iter::IterInnerOkOrElse;
|
||||
|
||||
|
||||
mod ui;
|
||||
|
|
|
@ -26,7 +26,7 @@ toml = "0.5.1"
|
|||
toml-query = "0.9.2"
|
||||
filters = "0.3.0"
|
||||
failure = "0.1.5"
|
||||
resiter = "0.3.0"
|
||||
resiter = "0.4.0"
|
||||
|
||||
libimagstore = { version = "0.10.0", path = "../../../lib/core/libimagstore" }
|
||||
libimagrt = { version = "0.10.0", path = "../../../lib/core/libimagrt" }
|
||||
|
|
|
@ -58,12 +58,12 @@ use failure::Fallible as Result;
|
|||
use failure::err_msg;
|
||||
use resiter::FilterMap;
|
||||
use resiter::AndThen;
|
||||
use resiter::IterInnerOkOrElse;
|
||||
|
||||
use libimagrt::runtime::Runtime;
|
||||
use libimagrt::application::ImagApplication;
|
||||
use libimagstore::iter::get::StoreIdGetIteratorExtension;
|
||||
use libimagstore::store::FileLockEntry;
|
||||
use libimagerror::iter::IterInnerOkOrElse;
|
||||
|
||||
use toml_query::read::TomlValueReadExt;
|
||||
use toml_query::read::TomlValueReadTypeExt;
|
||||
|
|
|
@ -24,7 +24,7 @@ log = "0.4.6"
|
|||
toml = "0.5.1"
|
||||
toml-query = "0.9.2"
|
||||
failure = "0.1.5"
|
||||
resiter = "0.3.0"
|
||||
resiter = "0.4.0"
|
||||
|
||||
libimagstore = { version = "0.10.0", path = "../../../lib/core/libimagstore" }
|
||||
libimagrt = { version = "0.10.0", path = "../../../lib/core/libimagrt" }
|
||||
|
|
|
@ -23,7 +23,7 @@ maintenance = { status = "actively-developed" }
|
|||
[dependencies]
|
||||
log = "0.4.6"
|
||||
failure = "0.1.5"
|
||||
resiter = "0.3.0"
|
||||
resiter = "0.4.0"
|
||||
|
||||
libimagstore = { version = "0.10.0", path = "../../../lib/core/libimagstore" }
|
||||
libimagrt = { version = "0.10.0", path = "../../../lib/core/libimagrt" }
|
||||
|
|
|
@ -50,12 +50,12 @@ use failure::err_msg;
|
|||
use failure::Fallible as Result;
|
||||
use resiter::AndThen;
|
||||
use resiter::Map;
|
||||
use resiter::IterInnerOkOrElse;
|
||||
use clap::App;
|
||||
|
||||
use libimagrt::runtime::Runtime;
|
||||
use libimagrt::application::ImagApplication;
|
||||
use libimagstore::iter::get::StoreIdGetIteratorExtension;
|
||||
use crate::libimagerror::iter::IterInnerOkOrElse;
|
||||
|
||||
mod ui;
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ maintenance = { status = "actively-developed" }
|
|||
[dependencies]
|
||||
log = "0.4.6"
|
||||
failure = "0.1.5"
|
||||
resiter = "0.4.0"
|
||||
|
||||
libimagrt = { version = "0.10.0", path = "../../../lib/core/libimagrt" }
|
||||
libimagerror = { version = "0.10.0", path = "../../../lib/core/libimagerror" }
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
|
||||
#[macro_use] extern crate log;
|
||||
#[macro_use] extern crate failure;
|
||||
extern crate resiter;
|
||||
extern crate clap;
|
||||
|
||||
extern crate libimagrt;
|
||||
|
@ -54,10 +55,10 @@ use libimagstore::store::Store;
|
|||
use libimagstore::store::FileLockEntry;
|
||||
use libimagentrylink::linkable::Linkable;
|
||||
use libimagstore::iter::get::StoreIdGetIteratorExtension;
|
||||
use libimagerror::iter::IterInnerOkOrElse;
|
||||
|
||||
use failure::Fallible as Result;
|
||||
use failure::err_msg;
|
||||
use resiter::IterInnerOkOrElse;
|
||||
use clap::App;
|
||||
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ maintenance = { status = "actively-developed" }
|
|||
log = "0.4.6"
|
||||
toml = "0.5.1"
|
||||
failure = "0.1.5"
|
||||
resiter = "0.3.0"
|
||||
resiter = "0.4.0"
|
||||
|
||||
libimagstore = { version = "0.10.0", path = "../../../lib/core/libimagstore", features = ["verify"] }
|
||||
libimagrt = { version = "0.10.0", path = "../../../lib/core/libimagrt" }
|
||||
|
|
|
@ -22,9 +22,9 @@ use std::ops::Deref;
|
|||
use failure::Fallible as Result;
|
||||
use failure::err_msg;
|
||||
use resiter::AndThen;
|
||||
use resiter::IterInnerOkOrElse;
|
||||
|
||||
use libimagrt::runtime::Runtime;
|
||||
use libimagerror::iter::IterInnerOkOrElse;
|
||||
|
||||
/// Verify the store.
|
||||
///
|
||||
|
|
|
@ -26,7 +26,7 @@ toml-query = "0.9.2"
|
|||
handlebars = "2"
|
||||
tempfile = "3.0.9"
|
||||
failure = "0.1.5"
|
||||
resiter = "0.3.0"
|
||||
resiter = "0.4.0"
|
||||
|
||||
libimagstore = { version = "0.10.0", path = "../../../lib/core/libimagstore" }
|
||||
libimagrt = { version = "0.10.0", path = "../../../lib/core/libimagrt" }
|
||||
|
|
|
@ -60,6 +60,7 @@ use failure::Error;
|
|||
use failure::err_msg;
|
||||
use failure::Fallible as Result;
|
||||
use resiter::AndThen;
|
||||
use resiter::IterInnerOkOrElse;
|
||||
use clap::App;
|
||||
|
||||
use libimagrt::runtime::Runtime;
|
||||
|
@ -69,7 +70,6 @@ use libimagentryview::builtin::md::MarkdownViewer;
|
|||
use libimagentryview::viewer::Viewer;
|
||||
use libimagstore::iter::get::StoreIdGetIteratorExtension;
|
||||
use libimagstore::store::FileLockEntry;
|
||||
use libimagerror::iter::IterInnerOkOrElse;
|
||||
|
||||
mod ui;
|
||||
|
||||
|
|
|
@ -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)())))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in a new issue