How to stringify the expansion of paste?

Similar to this: Does the macro invocation within stringify! not work?

Is there a way to stringify paste's output? I want a struct's name in snake_case casing. paste is no longer maintained and hoping there's a miracle to still get it to work:

    #[test]
    fn test_stringify() {

        struct SomeStruct {
            stuff: u8
        }

        macro_rules! forward {
            ($name:ty) => {
                
                paste! ([<$name:snake>])
                
            };
        }

        let s: &str = forward!(SomeStruct);

        assert_eq!("some_struct", s)

        
    }

At one point an issue was filed with stringified but it appears resolved, yet I cannot manage to use stringify in this way: Conflict with extended_key_value_attributes · Issue #63 · dtolnay/paste · GitHub

I get:

error: unexpected punct
  --> src/string_the_test.rs:48:41
   |
48 |         let s: &str = forward!(stringify!(SomeStruct));
   |                                         ^


The stringify!() needs to happen inside of paste!'s invocation:

#[test]
    fn test_stringify() {

        struct SomeStruct {
            stuff: u8
        }

        macro_rules! forward {
            ($name:ty) => {
                paste! {
                    stringify!( [<$name:snake>] )
                 // ^^^^^^^^^^^                 ^
                }
            };
        }

        let s: &str = forward!(SomeStruct);

        assert_eq!("some_struct", s)

        
    }
2 Likes