lambdaworks
lambdaworks copied to clipboard
Rename traits
There is currently a naming convention on traits that they are supposed to start with something like Is
or Has
. We should get rid of it
With has
there shouldn't be any problems. But with is
, if we just remove them there will be a name collision between the concrete instantiation and the trait. So this should be taken in account for the refactor
Fwiw, naming the trait and the struct the same thing isn't the worst.
You could always partially or fully qualify the trait. For example, math::traits::Field
, which is fine as you likely only use the trait in one place per file.
You can also do a renaming import: use math::traits::Field as FieldTrait
.
Both are fine for clarity's sake and avoid awkward naming conventions.
Fwiw, naming the trait and the struct the same thing isn't the worst.
You could always partially or fully qualify the trait. For example,
math::traits::Field
, which is fine as you likely only use the trait in one place per file.You can also do a renaming import:
use math::traits::Field as FieldTrait
.Both are fine for clarity's sake and avoid awkward naming conventions.
I agree with this, we should take a similar approach.
The naming convention we used is: "Nouns only for structs". Every name that is not a noun is allowed for a trait. For example adjectives, verbs, or things like "IsSomething" are all allowed. The "Is" or "Has" prefix is not mandatory, but we found it more declarative in some cases, specially when you see variable types: where F: IsField
.
In my opinion it would be good if we have some kind of naming convention, it doesn't have to be this one necessarily.
The naming convention we used is: "Nouns only for structs". Every name that is not a noun is allowed for a trait. For example adjectives, verbs, or things like "IsSomething" are all allowed. The "Is" or "Has" prefix is not mandatory, but we found it more declarative in some cases, specially when you see variable types:
where F: IsField
.In my opinion it would be good if we have some kind of naming convention, it doesn't have to be this one necessarily.
I think the "Is" or "Has" or any prefix for that matter feels very un-rust-like. I feel in my rust experience most libraries would prefer to pub mod trait
and qualify the trait or import rename.