Giter Site home page Giter Site logo

Rename traits about lambdaworks HOT 5 OPEN

lambdaclass avatar lambdaclass commented on August 16, 2024
Rename traits

from lambdaworks.

Comments (5)

MauroToscano avatar MauroToscano commented on August 16, 2024

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

from lambdaworks.

gluax avatar gluax commented on August 16, 2024

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.

from lambdaworks.

ilitteri avatar ilitteri commented on August 16, 2024

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.

from lambdaworks.

ajgara avatar ajgara commented on August 16, 2024

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.

from lambdaworks.

gluax avatar gluax commented on August 16, 2024

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.

from lambdaworks.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.