mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 00:49:42 +08:00
refactor(router): move fp_utils module to common_utils crate (#391)
Co-authored-by: Arun Raj M <jarnura47@gmail.com> Co-authored-by: Nishant Joshi <nishant.joshi@juspay.in>
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
pub(crate) mod custom_serde;
|
||||
pub(crate) mod db_utils;
|
||||
mod ext_traits;
|
||||
mod fp_utils;
|
||||
|
||||
#[cfg(feature = "kv_store")]
|
||||
pub(crate) mod storage_partitioning;
|
||||
@ -9,14 +8,12 @@ pub(crate) mod storage_partitioning;
|
||||
pub(crate) use common_utils::{
|
||||
crypto,
|
||||
ext_traits::{ByteSliceExt, BytesExt, Encode, StringExt, ValueExt},
|
||||
fp_utils::when,
|
||||
validation::validate_email,
|
||||
};
|
||||
use nanoid::nanoid;
|
||||
|
||||
pub(crate) use self::{
|
||||
ext_traits::{OptionExt, ValidateCall},
|
||||
fp_utils::when,
|
||||
};
|
||||
pub(crate) use self::ext_traits::{OptionExt, ValidateCall};
|
||||
use crate::consts;
|
||||
|
||||
pub mod error_parser {
|
||||
|
||||
@ -1,31 +0,0 @@
|
||||
pub trait Applicative<R> {
|
||||
type WrappedSelf<T>;
|
||||
|
||||
fn pure(v: R) -> Self::WrappedSelf<R>;
|
||||
}
|
||||
|
||||
impl<R> Applicative<R> for Option<R> {
|
||||
type WrappedSelf<T> = Option<T>;
|
||||
fn pure(v: R) -> Self::WrappedSelf<R> {
|
||||
Some(v)
|
||||
}
|
||||
}
|
||||
|
||||
impl<R, E> Applicative<R> for Result<R, E> {
|
||||
type WrappedSelf<T> = Result<T, E>;
|
||||
fn pure(v: R) -> Self::WrappedSelf<R> {
|
||||
Ok(v)
|
||||
}
|
||||
}
|
||||
|
||||
// This function allows lazy evaluation of the `f` argument
|
||||
pub fn when<W: Applicative<(), WrappedSelf<()> = W>, F>(predicate: bool, f: F) -> W
|
||||
where
|
||||
F: FnOnce() -> W,
|
||||
{
|
||||
if predicate {
|
||||
f()
|
||||
} else {
|
||||
W::pure(())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user