Debian Codegraph @

third_party/rust/windows-strings/readme.md

raw
1 ## Windows string types
2
3 The [windows-strings](https://crates.io/crates/windows-strings) crate provides common Windows string types used by various Windows APIs.
4
5 * [Getting started](https://kennykerr.ca/rust-getting-started/)
6 * [Samples](https://github.com/microsoft/windows-rs/tree/0.58.0/crates/samples)
7 * [Releases](https://github.com/microsoft/windows-rs/releases)
8
9 Start by adding the following to your Cargo.toml file:
10
11 ```toml
12 [dependencies.windows-strings]
13 version = "0.1"
14 ```
15
16 Use the Windows string types as needed:
17
18 ```rust
19 use windows_strings::*;
20
21 const A: PCSTR = s!("ansi");
22 const W: PCWSTR = w!("wide");
23
24 fn main() -> Result<()> {
25 let b = BSTR::from("bstr");
26 let h = HSTRING::from("hstring");
27
28 assert_eq!(b, "bstr");
29 assert_eq!(h, "hstring");
30
31 assert_eq!(unsafe { A.to_string()? }, "ansi");
32 assert_eq!(unsafe { W.to_string()? }, "wide");
33
34 Ok(())
35 }
36 ```