-
Notifications
You must be signed in to change notification settings - Fork 268
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
Improve Message
constructors
#644
Conversation
With this PR we can use |
A few thoughts:
|
1aa72cf
to
2481cc6
Compare
Message
constructors
Observe: - The word "hash" can be a verb or a noun, its usage in function names is therefore at times ambiguous. - The function name `from_slice` gives no indication as to what the slice input is. Improve Message constructors by doing: - Add a constructor `Message::from_digest` that takes a 32 byte array as input. - Rename `Message::from_slice` to `Message::from_digest_slice` (deprecate `from_slice` and add `from_digest_slice`) - Improve the docs while we are at it.
2481cc6
to
cd40ae7
Compare
PR now does the first two points you suggest, will play with second two in a separate PR. |
Looks good! I have a mild preference to use |
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.
ACK cd40ae7
I got worried over night thinking about this because it introduces non-uniformity "why hash here and digest there?" since we barely use the word "digest" anywhere. I've been down this path before in years gone past and its a bit like pushing against the whole world. The "hash is a verb and noun" thing is a real problem though. |
Regarding |
Aside from the "more dependency lines" issue (and IMO I would rather deal with the hole than have a more complicated dep tree), I think we considered this and had some issue with the orphan rules and blanket impls. But I don't remember specifically where. |
We could have the dep tree complicated only until stabilization and then incur one last break. I'm willing to look at the orphan problem if this is acceptable. At the very least |
Observe:
from_slice
gives no indication as to what the slice input is.Improve Message constructors by doing:
Message::from_digest
that takes a 32 byte array as input.Message::from_slice
toMessage::from_digest_slice
(deprecatefrom_slice
and addfrom_digest_slice
)Note
The original PR conflate 2 separate issues, the
Message
constructor naming clarity issue and the upgrade difficulty issue, PR is now only a solution to the first. The second will be done as a separate PR.