cppstreams 1.1.0

C++ streams in rust
Documentation
pub struct DisplayWrapper<T: (Fn(&mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error>)>(T);

impl<T: (Fn(&mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error>)> DisplayWrapper<T> {
    #[inline]
    pub const fn new(value: T) -> Self {
        Self(value)
    }
}

impl<T: (Fn(&mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error>)> std::fmt::Display
    for DisplayWrapper<T>
{
    #[inline]
    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
        self.0(fmt)
    }
}

#[macro_export]
macro_rules! formatted {
    ($($arg:tt)*) => {
        {
            // capture the environment
            let fun = |fmt: &mut std::fmt::Formatter<'_>| write!(fmt, $($arg)*);

            $crate::formatting::DisplayWrapper::new(fun)
        }
    };
}

#[macro_export]
macro_rules! debug {
    ($arg:expr) => {
        $crate::formatted!("{:?}", $arg)
    };
}