Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Following Rust naming scheme #780

Open
kevaundray opened this issue Feb 9, 2023 · 7 comments
Open

Following Rust naming scheme #780

kevaundray opened this issue Feb 9, 2023 · 7 comments
Labels
enhancement New feature or request good first issue Good for newcomers refactor

Comments

@kevaundray
Copy link
Contributor

Problem

This is a tracking issue. There are places where we do not follow the Rust naming guidelines.

See: https://rust-lang.github.io/api-guidelines/naming.html

This file does not list all of the naming rules, so we can add a comment in here to specify ones which are used in the ecosystem but not widely documented. Eg. get_or_init , get_or_compute_foo

Solution

  • Fix me

Alternatives considered

Additional context

@kevaundray
Copy link
Contributor Author

@0xYYY fyi, opened this issue following our discussion

@0xYYY
Copy link
Contributor

0xYYY commented Feb 9, 2023

noted, thanks a lot, will also update with the cases that i found

@kevaundray
Copy link
Contributor Author

There are a few places where a method may return either a type T, an Option<T> or a Result<T, Error>. Here is what I suggest:

// This is according to rust naming scheme
fn foo() -> Foo;
// This is also in accordance to the document
fn get_foo() -> Option<Foo>;
fn try_foo() -> Result<Foo, Error>;

Note the document uses: fn get(&self, index: K) -> Option<&V>; but this assumes that there is only one type to return which is the case with a map. If this is also the case for us, then we can unambiguously use that too.

CC @jfecher

@TomAFrench TomAFrench added the good first issue Good for newcomers label Apr 4, 2023
@makluganteng
Copy link

Can i take this task ?

@kevaundray
Copy link
Contributor Author

Can i take this task ?

That would be amazing - note:

  • This is an continuous issue, so it probably won't be closed.
  • if you see a change that needs to be made widespread, I suggest to make a small PR with that change to see if it's something we want to adopt, so it saves you time

@makluganteng
Copy link

aa i see maybe i could take on other issue along the way coz its a long term kinda thing

@kevaundray
Copy link
Contributor Author

aa i see maybe i could take on other issue along the way coz its a long term kinda thing

That would be great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers refactor
Projects
Status: 📋 Backlog
Development

No branches or pull requests

5 participants