makeover-webview 0.130.0

The webview renderer for makeover-layout. Emits CSS, and is the one renderer that needs no palette: var() is the late binding, so resolution stays with the browser. With the build feature, writes a consumer's generated frontend files and checks the hand-written ones against them.
Documentation
//! `write!` and `writeln!` for the `String`s this crate emits into, without a
//! `Result` to discard: a `String` accepts every write.

use std::fmt::{Arguments, Write as _};

/// Appends formatted text to a `String`, as `write!` does.
macro_rules! put {
    ($dst:expr, $($arg:tt)*) => {{
        use $crate::put::Put as _;
        $dst.put(format_args!($($arg)*))
    }};
}

/// Appends formatted text and a newline to a `String`, as `writeln!` does.
macro_rules! putln {
    ($dst:expr, $($arg:tt)*) => {{
        use $crate::put::Put as _;
        $dst.put_line(format_args!($($arg)*))
    }};
}

pub(crate) trait Put {
    fn put(&mut self, args: Arguments<'_>);
    fn put_line(&mut self, args: Arguments<'_>);
}

impl Put for String {
    fn put(&mut self, args: Arguments<'_>) {
        self.write_fmt(args)
            .expect("formatting into a String fails only when a Display impl does");
    }

    fn put_line(&mut self, args: Arguments<'_>) {
        self.put(args);
        self.push('\n');
    }
}

#[cfg(test)]
mod tests {
    #[test]
    fn put_and_putln_append_as_write_and_writeln_do() {
        let mut out = String::from("a");
        let n = 2;
        put!(out, "-{n}");
        putln!(out, " {}", "b");
        let target = &mut out;
        putln!(target, "c");
        assert_eq!(out, "a-2 b\nc\n");
    }
}