pub const trait IntoPatch<T>: Sized {
#[must_use]
fn into_value(self) -> T;
}
impl<T: Sized + [const] FromPatch<O>, O> const IntoPatch<T> for O {
fn into_value(self) -> T {
T::from_value(self)
}
}
pub const trait FromPatch<T>: Sized {
#[must_use]
fn from_value(value: T) -> Self;
}
mod numbers;
#[cfg(feature = "std")]
mod hashmap;
#[cfg(feature = "std")]
mod hashset;
#[cfg(feature = "std")]
mod string;
#[cfg(feature = "std")]
mod vec;
mod tuple;
#[cfg(feature = "tokio")]
mod asynchronous;
#[cfg(feature = "std")]
crate::impl_from_patch_self!(std::time::SystemTime);
impl<T1, T2: FromPatch<T1>> FromPatch<Option<T1>> for Option<T2> {
fn from_value(value: Option<T1>) -> Self {
value.map(T2::from_value)
}
}
impl<T1, T2: FromPatch<T1>, E1, E2: FromPatch<E1>> FromPatch<Result<T1, E1>>
for Result<T2, E2>
{
fn from_value(value: Result<T1, E1>) -> Self {
match value {
Err(e) => Err(E2::from_value(e)),
Ok(v) => Ok(T2::from_value(v)),
}
}
}
#[cfg(feature = "std")]
impl<T1, T2: FromPatch<T1>> FromPatch<Box<T1>> for Box<T2> {
fn from_value(value: Box<T1>) -> Self {
Self::new(T2::from_value(*value))
}
}
impl<T: Clone> FromPatch<&T> for T {
default fn from_value(value: &T) -> Self {
value.clone()
}
}
impl<T1, T2: FromPatch<T1>> FromPatch<core::cell::Cell<T1>>
for core::cell::Cell<T2>
{
fn from_value(value: core::cell::Cell<T1>) -> Self {
Self::new(T2::from_value(value.into_inner()))
}
}
impl<T1, T2: FromPatch<T1>> FromPatch<core::cell::RefCell<T1>>
for core::cell::RefCell<T2>
{
fn from_value(value: core::cell::RefCell<T1>) -> Self {
Self::new(T2::from_value(value.into_inner()))
}
}
impl<T1, T2: FromPatch<T1>> FromPatch<core::cell::RefCell<T1>>
for core::cell::Cell<T2>
{
fn from_value(value: core::cell::RefCell<T1>) -> Self {
Self::new(T2::from_value(value.into_inner()))
}
}
impl<T1, T2: FromPatch<T1>> FromPatch<core::cell::Cell<T1>>
for core::cell::RefCell<T2>
{
fn from_value(value: core::cell::Cell<T1>) -> Self {
Self::new(T2::from_value(value.into_inner()))
}
}
impl<'a> FromPatch<&'a str> for &'a [u8] {
fn from_value(value: &'a str) -> Self {
value.as_bytes()
}
}