Length of repeating macro argument as integer

What is the best way to get the length of a repeating macro argument as an integer in the expansion?
The one I'm currently using is the following:

macro_rules! test {
    ($($name:ident : $ty:ty),+) => {
        struct X {
            $($name: $ty),+
        }
        impl X {
            fn len(&self) -> usize {
                [$(stringify!($name)),+].len()
            }
        }
    }
}

i.e. construct an array of static strings and take its len(). In release mode it's properly optimized out, but in debug mode it carries the whole useless static array around. Is there a nicer way?

Thanks, that's a nice one for the general case where you might have lots of items.

Needs a helper macro though, but that's not a big deal. In the meantime I found the helper macro approach as well, with a simpler one:

macro_rules! one { ($anything:tt) => (1) }