Skip to content

0.5.2: singleton!

Compare
Choose a tag to compare
@dhardy dhardy released this 06 Oct 12:50
· 69 commits to master since this release
fe651f1

[0.5.2] — 2022-10-06

  • Add singleton! macro (#25)
use std::fmt;
fn main() {
    let world = "world";
    let says_hello_world = impl_tools::singleton! {
        struct(&'static str = world);
        impl fmt::Display for Self {
            fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
                write!(f, "hello {}", self.0)
            }
        }
    };
    assert_eq!(format!("{}", says_hello_world), "hello world");
}