Windows-rs: PWSTR does not implement Debug/Display

Created on 9 Mar 2021  ·  4Comments  ·  Source: microsoft/windows-rs

This type should implement both debug and display. The Display implementation seems obvious (we should just print the string contents). Should the Debug implementation be the same? Since PWSTR is often used at the ABI barrier, it might make sense to show the value of the ptr itself as well.

enhancement

Most helpful comment

that assumes correctly created values, which you cannot do with public fields.

println!("{}", PWSTR(4 as _)); // gonna be a bad time

All 4 comments

That would be unsound. (Displaying the memory I mean.)

@Lokathor Why would this be unsound? I think if the ptr is non-null the contents should be fine to read and display.

that assumes correctly created values, which you cannot do with public fields.

println!("{}", PWSTR(4 as _)); // gonna be a bad time

That's very true. We'll probably have to create an unsafe display function much like std::path::Path::display (which isn't unsafe).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rylev picture rylev  ·  5Comments

ZCWorks picture ZCWorks  ·  3Comments

bdbai picture bdbai  ·  3Comments

Zymlex picture Zymlex  ·  3Comments

13r0ck picture 13r0ck  ·  4Comments