-
Notifications
You must be signed in to change notification settings - Fork 110
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
Remove some Identity conversions that could panic #1966
base: master
Are you sure you want to change the base?
Conversation
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.
This is a good idea. I was just retouching these and didn't like that unwrap
. However, it is an API break. My concern was that from_slice
might already be being used by clients so I wasn't sure about changing it. from_be_slice
is definitely fine to remove since it was just added.
We could also change them to return Option<Self>
instead.
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.
Thanks for cleaning this up. One minor terminology request: in the future, please don't use "unsafe" to describe Rust code unless it is unsafe
, i.e. liable to invoke UB. Your PR title made me somewhat worried about this, when the actual changes are trivial and easy to approve.
Spurious test failure should be fixed by #1979 . Please rebase onto master or merge master into this branch, at your preference, to confirm. |
Description of Changes
This removes
Identity::{from_slice,from_be_slice}
, which previously had the potential to panic. Since callers can just usetry_into
, I don't think we need this in the API.API and ABI breaking changes
This removes two functions from the
Identity
lib. If we find that these are widely used, we could add back a safe version. Making this safe will always be a breaking change though, since we need to change the return type to a Result.Expected complexity level and risk
1
Testing
Not much added testing, since this is a pretty mechanical change.