#![cfg_attr(doc, doc = include_str!("../README.md"))]
#![expect(
clippy::pub_use,
clippy::blanket_clippy_restriction_lints,
clippy::arbitrary_source_item_ordering,
clippy::missing_trait_methods,
clippy::implicit_return,
reason = "re-exports"
)]
#![allow(clippy::missing_docs_in_private_items, reason = "expect doesn't work")]
#![no_std]
use ::core::convert::Infallible;
#[cfg(feature = "macros")]
pub use ::pud_macros::pud;
pub trait Pud {
type Target;
fn apply(self, target: &mut Self::Target);
}
pub trait Pudded: Sized {
#[inline]
fn apply(&mut self, pud: impl Pud<Target = Self>) {
pud.apply(self);
}
#[inline]
fn apply_batch(&mut self, puds: impl Iterator<Item = impl Pud<Target = Self>>) {
puds.for_each(|pud| pud.apply(self));
}
}
impl<T: Sized> Pudded for T {}
pub trait IntoPud {
type Pud: Pud;
fn into_pud(self) -> Self::Pud;
}
pub trait TryIntoPud {
type Pud: Pud;
type Error;
fn try_into_pud(self) -> Result<Self::Pud, Self::Error>;
}
impl<T> TryIntoPud for T
where
T: IntoPud,
{
type Pud = T::Pud;
type Error = Infallible;
#[inline]
fn try_into_pud(self) -> Result<Self::Pud, Self::Error> {
Ok(self.into_pud())
}
}