-
Notifications
You must be signed in to change notification settings - Fork 316
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
refactor: cleanup imports and remove globs #1394
Conversation
@DrPeterVanNostrand Nice -- I should be done reviewing this tomorrow. Based on this, I'm anticipating a very unfriendly rebase on my local branch work (hopefully can be sorted out tomorrow too though). |
I'm in the "almost never use" globs camp. I find code easier to navigate if I can grep for things. Even for those two cases:
If things are deeply nested, things "bubble" up automatically and you might accidentally put something into the top-level API. I also think the top-level API shouldn't cluttered. I'm not sure if that's best practice, but what I sometimes do is putting the widely used things into the top-level, but leaving very specific things (which might be still useful, hence are public) within a module. What I also did in the past was putting a generic version of some type into the module, but putting a specific version on the top level. So it's kind of a re-export with the same name. Though there are cases where a glob might be appropriate, though I wouldn't say it's generally the case.
I also usually don't do that as I like copy&pastable tests. Often tests are the best documentation a library has and they are a good starting point. Though there I can totally see that one prefers using a glob, so I'm not oppose if someone is using a glob there. In the PR I've seen that you directly import functions. I usually follow the rust style guidelines where you don't import functions, but only their module. E.g: use rand::Rng;
…
let bytes = rand::thread_rng().gen::<[u8; 32]>();
// and not
use rand::{thread_rng, Rng};
…
let bytes = thread_rng().gen::<[u8; 32]>(); |
I'm ok with whatever convention we go with, as I think striving for consistency is most important when it comes to style -- but I find the former more readable, as the context is more quickly found. |
Only ~25 files left 😅 So far, this all looks very straight-forward. Like I said, there are some inconsistencies here and there, but overall looks much better to me. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[haven't reviewed all files in detail] general rules and things I saw look good to me, I'll leave the detailed check to @cryptonemo
I should've noted that my comment was about my preference and how I do it and not a request that we must do it this way. I certainly don't wan to to block anything and this PR improves things for sure. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
@DrPeterVanNostrand are you still changing things here, or can this be merged? |
@DrPeterVanNostrand indicated on the call that some changes were incoming, so I believe we're waiting on a last push. |
Sorry, pushing my changes this morning |
ed06da1
99f5f50
to
ed06da1
Compare
Changes have been pushed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks! (Yay for github, remembering my previously reviewed files)
Awesome, thank you for reviewing it again. Should I merge now, or wait for other PR's to merge? |
Merge at will! |
@cryptonemo thanks, doing now |
This commit leads to a problem that on ARM platform, the mod sha256_intrinsics can't be imported. error[E0432]: unresolved import |
@dbshch Thank you for noting this -- we are going to be looking into the ARM platform in the future. Can you create a top-level issue for what you're seeing on this for tracking it? |
when re-exporting in
lib.rs
/mod.rs
files:in unit test submodules:
enum
variant imports: