1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
pub use crate::config::{matchable::Matchable, parameter_matchable::ParameterMatchable};
pub trait IntoString {
fn into_string(self) -> String;
}
pub trait MapAny<T> {
fn map_any<F: FnOnce(T) -> T>(self, op: F) -> Self;
}
impl<T> MapAny<T> for Result<T, T> {
fn map_any<F: FnOnce(T) -> T>(self, op: F) -> Self {
match self {
Ok(x) => Ok(op(x)),
Err(x) => Err(op(x)),
}
}
}
pub trait MaybeRef<T> {
fn maybe_ref(&self) -> Option<&T>;
fn to_ref(&self) -> &T;
}
pub trait MaybeRefAs {
fn maybe_ref_as<T>(&self) -> Option<&T>
where
Self: MaybeRef<T>;
fn to_ref_as<T>(&self) -> &T
where
Self: MaybeRef<T>;
}
|