Macro list separated by plus

Hopefully there's some kind of escape sequence for this.

    pub fn dot(self, rhs: Self) -> f64 {
        $( self.$x * rhs.$x )++

Don't believe so.

Split $x into a head and tail, then use $head $(+ $tail)*.

Thanks, that's a good idea, but it makes all the other uses of the list messier. :frowning:

Here's what I'm doing right now:

        let mut dot = 0.0;
        $( dot += self.$x * rhs.$x; )+

Combining the ideas, maybe 0.0 $(+ self.$x * rhs.$x)+ would do the trick.

1 Like