-
Notifications
You must be signed in to change notification settings - Fork 74
Fixing minor things #8
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
Conversation
sgeisler
left a comment
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, only left some minor nits.
|
|
||
| match iter.next() { | ||
| // If all languages were eliminated, it's an invalid word. | ||
| None => return Err(Error::UnknownWord(idx)), |
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.
Minor nit, please don't change it unless you deem it important yourself: technically it doesn't have to be the current word that was "invalid", it could have been any word before that, that happened to exclude some language that was actually meant. The common case is "this is an invalid word" though, so it makes a lot of sense to not overcomplicate it.
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.
Good point. I agree that this is the best way to return it though. Majority of cases an accidental invalid word will not by chance be valid in a random wrong language 😅
Cargo.toml
Outdated
| [features] | ||
| default = [ "std" ] | ||
| std = [ "serde/std" ] | ||
| core = [] |
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.
Is there any reason ever not to have core available? Does feature gating it make any sense? That feels like saying "oh, we might be missing basic arithmetic on some platforms" 😆.
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.
ah yeah true, core is always there, my bad, I was confused.
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.
pushed a fix
| /// Generate a new [Mnemonic] in the given language. | ||
| /// For the different supported word counts, see documentation on [Mnemonic]. | ||
| #[cfg(feature = "rand")] | ||
| pub fn generate_in(language: Language, word_count: usize) -> Result<Mnemonic, Error> { |
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.
I wonder if this should stay in here for convenience or should be thrown out for increased focus …. If SemVer is a concern: maybe it can be deprecated?
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.
eh I think it's ok. I like that you don't have to fiddle with rand to use this.
|
Awesome, LGTM! |
| #[cfg(feature = "rand")] | ||
| #[test] | ||
| fn test_generate() { | ||
| let _ = Mnemonic::generate(24).unwrap(); |
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.
Maybe these could be doctests, so that they are also improving docs (not everyone might be aware of rand_core's relation to rand)?
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.
Otoh, only one of these is really interesting …
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.
Hmm, good point :D will do
82b9914 to
e990720
Compare
e990720 to
04e139c
Compare
|
I consider that LGTM + nit as an ack 😅 |
Based on comments from @sgeisler in #6.