-
Notifications
You must be signed in to change notification settings - Fork 531
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
Add Deref
implementation for HSTRING
#3291
Conversation
Build break is due to unrelated Rust nightly update - investigating. Workaround is here: #3292 |
Nice! |
|
||
pub fn len(&self) -> usize { | ||
if self.0.is_null() { | ||
fn deref(&self) -> &[u16] { |
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.
What's the reason for this signature rather than its more conventional spelling
fn deref(&self) -> &Self::Target
?
I'm just curious if there's a particular reason.
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.
No reason, just seemed more succinct in this case.
The
HSTRING
type represents a UTF-16 string that is modeled as a[u16]
slice in Rust. This update replaces theas_wide
method to retrieve theHSTRING
as a slice with aDeref
implementation. This makes it a lot easier to work with anHSTRING
in Rust as conversion is implicit in many cases.The same is done for
BSTR
for consistency and code reduction.Fixes: rust-lang/rustup#3896 (comment)