Repository navigation
Borrowed - #1811
Borrowed#1811
Conversation
7f96cc4 to
9da179c
Compare
| @@ -156,13 +156,13 @@ impl Window { | |||
| target.SetTarget(clock); | |||
| target.Clear(std::ptr::null()); | |||
| self.draw_clock()?; | |||
| target.SetTarget(previous); | |||
| target.SetTarget(previous.as_ref()); | |||
There was a problem hiding this comment.
Seems to have lost my previous comments on the other commit. Ideally this would be &previous if we can make Borrowed creatable from &Option<T>.
There was a problem hiding this comment.
Unfortunately, this is not possible as Rust's type system doesn't know that &Option<T> does not implement Into<&'a T> and thus we get a conflicting impl error if I add an implementation to make &Option<T> work. It's unfortunate, but workable IMO.
6306406 to
53f70a1
Compare
|
As far as I'm aware, the following are the things left to address before we merge this:
|
60bfd30 to
2dd65ba
Compare
| @@ -3,7 +3,7 @@ use windows::Foundation::{IStringable, PropertyValue, Uri}; | |||
|
|
|||
| #[test] | |||
| fn class() -> windows::core::Result<()> { | |||
| let uri = Uri::CreateUri("http://kennykerr.ca")?; | |||
| let uri = Uri::CreateUri(&windows::core::HSTRING::from("http://kennykerr.ca"))?; | |||
There was a problem hiding this comment.
Perhaps we just need to have a universal PCWSTR type for all wide string input parameters to avoid the complication of dealing with the various different types. Then we can specialize that one to handle all the marshaling under the hood - that should simplify and harmonize the various calling patterns for strings. Not for this PR but need to land that fairly closely along with this.
60c97ff to
2efd13e
Compare
|
Are there any plans to address the situation with string parameters? Having to use |
|
This is a tricky question: Automatically converting from In fact, this was the reason that the previous For string literals, the |
This implements the Borrow Type RFC which makes conversion to input parameters much more straightforward.
Changes
There are some changes in this PR from the RFC:
Changes to Borrowed
During development, it was discussed how
Borrowedtypes are always logically optional. This PR adjusts the definition ofBorrowedto be a wrapper around<T as Abi>::Abi.Addition of
InParamAdditionally, an
InParamtype is added which is essentially either an ownedTor aBorrowed<'a, T>. This allows us to hold on params that have been converted to the correct type at the last minute dropping them at the end of the function call.Changes to the user experience
The following are the practical changes to the UX of the
windowscrate after this change:HSTRINGandPCWSTR(and kin) gets worseDefault::default()to a lot of places but now you need to be explicit with the typeURI_CREATE_FLAGS::default()To view the changes without codegen, look here