#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#[cfg(feature = "iterator")]
mod iterator;
#[cfg(feature = "result")]
mod result;
#[cfg(feature = "stream")]
mod stream;
#[cfg(feature = "result")]
pub trait ResultExt {
type T;
type E;
#[track_caller]
fn expect_with<M, F: FnOnce() -> M>(self, f: F) -> Self::T
where
Self::E: std::fmt::Debug,
M: AsRef<str>;
#[track_caller]
fn expect_or_report(self, msg: &str) -> Self::T
where
Self::E: std::error::Error;
#[track_caller]
fn expect_or_report_with<M, F: FnOnce() -> M>(self, f: F) -> Self::T
where
Self::E: std::error::Error,
M: AsRef<str>;
#[track_caller]
fn unwrap_or_report(self) -> Self::T
where
Self::E: std::error::Error;
}
#[cfg(feature = "stream")]
pub trait StreamExt {
fn chain_ready<T>(self, item: T) -> futures::stream::Chain<Self, futures::stream::Once<std::future::Ready<T>>>
where
Self: Sized,
Self: futures::Stream<Item = T>;
fn chain_future<T, F>(self, fut: F) -> futures::stream::Chain<Self, futures::stream::Once<F>>
where
Self: Sized,
Self: futures::Stream<Item = T>,
F: core::future::Future<Output = T>;
}
#[cfg(feature = "iterator")]
pub trait IteratorExt {
fn map_into<U>(self) -> iterator::map_into::MapInto<Self, U>
where
Self: Sized,
Self: Iterator,
<Self as Iterator>::Item: Into<U>;
fn map_opt<T, U, F>(self, f: F) -> iterator::map_opt::MapOpt<Self, F>
where
Self: Sized,
Self: Iterator<Item = Option<T>>,
F: FnMut(T) -> U;
fn map_res<F, T, U, E>(self, f: F) -> iterator::map_res::MapRes<Self, F>
where
Self: Sized,
Self: Iterator<Item = Result<T, E>>,
F: FnMut(T) -> U;
fn map_res_err<F, T, U, E>(self, f: F) -> iterator::map_res_err::MapResErr<Self, F>
where
Self: Sized,
Self: Iterator<Item = Result<T, E>>,
F: FnMut(E) -> U;
fn join_as_strings(self, separator: &str) -> String
where
Self: Iterator,
<Self as Iterator>::Item: ToString;
}