typestring 0.1.0

String constants lifted into types. This is a stopgap until const generics support strings.
Documentation
/// A trait implemented by a lifted string type.
pub trait LiftedString {
    /// The value of this string.
    const VALUE: &'static str;
}

/// Used to generate type-level string constants.
#[macro_export]
macro_rules! typestring {
    (
        $(
            $(# $attr:tt)*
            $vis:vis type $name:ident = $val:literal ;
        )*
    ) => {
        $(
            $(# $attr)*
            #[derive(Default)]
            $vis struct $name ;

            impl $crate::LiftedString for $name {
                const VALUE: &'static str = $val;
            }
        )*
    };
}

mod test {
    use super::*;

    typestring! {
        type Foo = "foo";

        #[derive(Debug)]
        type Bar = "bar";
    }

    #[test]
    fn test_values_are_correct() {
        assert_eq!(Foo::VALUE, "foo");
        assert_eq!(Bar::VALUE, "bar");
    }
}