What is a unit variant

Event::Quit is a variant that has a named field, timestamp; variants with named fields are called struct variants. A variant with no fields is called a unit variant. A variant with unnamed (ie positional) fields is called a tuple variant.

So when you’re matching against a struct variant, you can say {..} if you don’t care about matching or capturing the field(s) values.

5 Likes