You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Cursor related const's such as IDC_ARROW in Windows\Win32\UI\WindowsAndMessaging\mod.rs are only compatible with the wide LoadCursorW function and not with the non-wide LoadCursorA function.
This is due to the const's being declared as PCWSTR's and not PCSTR's. However, switching would break the wide version of the function.
I'm new to Rust, so I may be missing an easy solution here. However, I think this use case should be supported, no?
Error:
error[E0277]: the trait bound `PCWSTR: CanInto<PCSTR>` is not satisfied
--> src\main.rs:5:49
|
5 | let version = LoadCursorA(HINSTANCE(0), IDC_ARROW);
| ----------- ^^^^^^^^^ the trait `CanInto<PCSTR>` is not implemented for `PCWSTR`
| |
| required by a bound introduced by this call
|
= help: the following other types implement trait `CanInto<T>`:
<IAgileObject as CanInto<IUnknown>>
<IAgileReference as CanInto<IUnknown>>
<IErrorInfo as CanInto<IUnknown>>
<ILanguageExceptionErrorInfo as CanInto<IUnknown>>
<ILanguageExceptionErrorInfo2 as CanInto<IUnknown>>
<ILanguageExceptionErrorInfo2 as CanInto<ILanguageExceptionErrorInfo>>
<IPropertyValue as CanInto<IUnknown>>
<IPropertyValue as CanInto<IInspectable>>
and 12 others
= note: required for `PCWSTR` to implement `IntoParam<PCSTR, CopyType>`
note: required by a bound in `WindowsAndMessaging::LoadCursorA`
--> C:\Users\Michael\.cargo\registry\src\index.crates.io-6f17d22bba15001f\windows-0.52.0\src\Windows\Win32\UI\WindowsAndMessaging\mod.rs:2260:9
|
2257 | pub unsafe fn LoadCursorA<P0, P1>(hinstance: P0, lpcursorname: P1) -> ::windows_core::Result<HCURSOR>
| ----------- required by a bound in this function
...
2260 | P1: ::windows_core::IntoParam<::windows_core::PCSTR>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `LoadCursorA`
Crate manifest
[package]
name = "CursorIssue"version = "0.1.0"edition = "2021"# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies.windows]
version = "0.52"features = [
"Win32_Foundation",
"Win32_UI_WindowsAndMessaging"
]
Crate code
use windows::Win32::{Foundation::*,UI::WindowsAndMessaging::*};fnmain(){unsafe{let version = LoadCursorA(HINSTANCE(0),IDC_ARROW);// Does not worklet wide_version = LoadCursorW(HINSTANCE(0),IDC_ARROW);// Works}}
The text was updated successfully, but these errors were encountered:
riverar
added
broken api
An API is inaccurate and could lead to runtime failure
rust
Critical for Rust adoption
and removed
bug
Something isn't working
labels
Dec 1, 2023
Not sure yet, do we have any other examples of how we've incorporated constants into metadata that change (in type), depending on the value of _UNICODE?
I don't believe so. We build for UNICODE. In cases where this is an explicit _A variant of the constant, we decorate that variant with the NativeEncoding(ansi) attribute, but I don't recall supporting conditional values for the same constant.
Summary
Cursor related const's such as
IDC_ARROW
in Windows\Win32\UI\WindowsAndMessaging\mod.rs are only compatible with the wideLoadCursorW
function and not with the non-wideLoadCursorA
function.This is due to the const's being declared as
PCWSTR
's and notPCSTR
's. However, switching would break the wide version of the function.I'm new to Rust, so I may be missing an easy solution here. However, I think this use case should be supported, no?
Error:
Crate manifest
Crate code
The text was updated successfully, but these errors were encountered: