-
Notifications
You must be signed in to change notification settings - Fork 592
Allow Error and Result<()> to be the same size as HRESULT
#3126
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
Merged
kennykerr
merged 17 commits into
microsoft:master
from
sivadeilra:user/ardavis/feature-get-error
Jun 26, 2024
Merged
Changes from 6 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
0869c27
snapshot
sivadeilra b6c3d77
switch to slim-errors
sivadeilra 60e243c
update workflow
sivadeilra d30af76
fix linux tests
sivadeilra a250607
Merge remote-tracking branch 'origin/master' into user/ardavis/featur…
sivadeilra b5c861a
fix cfg
sivadeilra db9c87d
fix natvis
sivadeilra 4f3196a
fix msrv-related issue
sivadeilra 88d911c
PR feedback; default; Error::empty
sivadeilra de1c33a
fix error in test case
sivadeilra 95bb373
move back to features, PR feedback
sivadeilra 526f7bc
Merge remote-tracking branch 'origin/master' into user/ardavis/featur…
sivadeilra cf10792
fix dead code warning in ComPtr, update natvis
sivadeilra 9f5c73d
specify features in a sample
sivadeilra 00d7345
switch to --cfg
sivadeilra f04a949
natvis
sivadeilra 7e5c760
pr feedback
sivadeilra File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| use super::*; | ||
|
|
||
| #[repr(transparent)] | ||
| pub struct BasicString(*const u16); | ||
|
|
||
| impl BasicString { | ||
| pub fn is_empty(&self) -> bool { | ||
| self.len() == 0 | ||
| } | ||
|
|
||
| pub fn len(&self) -> usize { | ||
| if self.0.is_null() { | ||
| 0 | ||
| } else { | ||
| unsafe { SysStringLen(self.0) as usize } | ||
| } | ||
| } | ||
|
|
||
| pub fn as_wide(&self) -> &[u16] { | ||
| let len = self.len(); | ||
| if len != 0 { | ||
| unsafe { core::slice::from_raw_parts(self.as_ptr(), len) } | ||
| } else { | ||
| &[] | ||
| } | ||
| } | ||
|
|
||
| pub fn as_ptr(&self) -> *const u16 { | ||
| if !self.is_empty() { | ||
| self.0 | ||
| } else { | ||
| const EMPTY: [u16; 1] = [0]; | ||
| EMPTY.as_ptr() | ||
| } | ||
| } | ||
| } | ||
|
|
||
| impl Default for BasicString { | ||
| fn default() -> Self { | ||
| Self(core::ptr::null_mut()) | ||
| } | ||
| } | ||
|
|
||
| impl Drop for BasicString { | ||
| fn drop(&mut self) { | ||
| if !self.0.is_null() { | ||
| unsafe { SysFreeString(self.0) } | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.