The correctness of use the word type to refer to some language element

When we have some struct T, we usually refer to T as a type.

pub struct Player;

and we can say, the type player.

But what if it’s a trait instead?

pub trait Player {}

is correct to refer to the trait player with the word type? Or they have another nomenclature, word or similar?

What about the enumerated types? Is that correct?

pub enum Player {

where we can refer to the enum as the enumerated type Player, or just the type player.

>Solution :

Per Wikipedia (emphasis mine),

In computer science and computer programming, a data type (or simply type) is a set of possible values and a set of allowed operations on it.

As traits don’t contain values it is incorrect to call them types. As enums do it is correct to do so.

Leave a Reply