-
Notifications
You must be signed in to change notification settings - Fork 44
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
Do not throw error if alterFunc
does not change the original key
#249
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.
Good catch, thanks!
A couple of minor comments.
mapstr/mapstr.go
Outdated
return fmt.Errorf("replacement key %q already exists: %w", newKey, ErrKeyCollision) | ||
|
||
// if altered key is equal to the original key, skip below delete/put func | ||
if newKey != key { |
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 think it would be more readable if it was just:
if newKey == key {
return nil
}
Co-authored-by: Denis <denis@rdner.de>
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.
LGTM, just an enhancement comment.
💚 Build Succeeded
History
|
What does this PR do?
We do not throw error if
alterFunc
does not change the original key. This also improves error message for when key is not foundWhy is it important?
Checklist