Join static strings

I want a macro, that joins some static strings with a separator, so that
expected!("a", "b", "c")
becomes
"a or b or c"

My current approach

macro_rules! expected {
    ( $( $value:expr ),*) => {
       concat!( $($value, " or ",),*)
    }
}

which expands to
"a or b or c or "

Is there any way to remove the trailing or without converting it to a String, so the macro expands to
"a or b or c"?

please note that this post has been written on mobile and therefore the examples might be invalid.

macro_rules! expected {
    ($head:literal $(, $tail:literal)*) => (concat!($head $(, " or ", $tail)*))
}
6 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.