Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename
RawPtr::to_option()
to RawPtr::as_ref()
As outlined in https://aturon.github.io/style/naming/conversions.html `to_` functions names should only be used for expensive operations. Thus `to_option` is better named `as_option`. Also, putting type names into method names is considered bad style; what the user is really trying to get is a reference. This `as_ref` is even better. Also, we are missing a mutable version of this method. So add a new trait `RawMutPtr` with a corresponding `as_mut` methode. Finally, there is a bug in the signature of `to_option` which has been around since lifetime elision: originally the returned reference had 'static lifetime, but since the elision changes this become the lifetime of the raw pointer (which does not make sense, since the pointer lifetime and referent lifetime are unrelated). Fix the bug to return a reference with a fresh lifetime (which will be inferred from the calling context). [breaking-change]
- Loading branch information
Showing
4 changed files
with
70 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
00ff5aa
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.
saw approval from aturon
at apoelstra@00ff5aa
00ff5aa
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.
merging apoelstra/rust/to-option-fix = 00ff5aa into auto
00ff5aa
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.
apoelstra/rust/to-option-fix = 00ff5aa merged ok, testing candidate = 6ac4a30
00ff5aa
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.
all tests pass:
success: http://buildbot.rust-lang.org/builders/auto-mac-32-opt/builds/1149
success: http://buildbot.rust-lang.org/builders/auto-mac-64-opt/builds/1149
success: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-c/builds/1148
success: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-t/builds/1149
success: http://buildbot.rust-lang.org/builders/auto-linux-32-opt/builds/1144
success: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-c/builds/1145
success: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-t/builds/1144
success: http://buildbot.rust-lang.org/builders/auto-linux-64-opt/builds/1150
success: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-c/builds/1145
success: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-t/builds/1144
success: http://buildbot.rust-lang.org/builders/auto-linux-64-x-android-t/builds/1147
success: http://buildbot.rust-lang.org/builders/auto-win-32-opt/builds/1148
success: http://buildbot.rust-lang.org/builders/auto-win-32-nopt-t/builds/1146
success: http://buildbot.rust-lang.org/builders/auto-win-32-nopt-c/builds/1147
00ff5aa
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.
fast-forwarding master to auto = 6ac4a30