Reputation: 2209
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 {
Soccer,
Rugby,
Basket
}
where we can refer to the enum as the enumerated type Player, or just the type player.
Upvotes: 1
Views: 40
Reputation: 70890
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.
Upvotes: 1