1
0
Fork 0
firefox/third_party/rust/windows-strings
Daniel Baumann 5e9a113729
Adding upstream version 140.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
2025-06-25 09:37:52 +02:00
..
src Adding upstream version 140.0. 2025-06-25 09:37:52 +02:00
.cargo-checksum.json Adding upstream version 140.0. 2025-06-25 09:37:52 +02:00
Cargo.toml Adding upstream version 140.0. 2025-06-25 09:37:52 +02:00
license-apache-2.0 Adding upstream version 140.0. 2025-06-25 09:37:52 +02:00
license-mit Adding upstream version 140.0. 2025-06-25 09:37:52 +02:00
readme.md Adding upstream version 140.0. 2025-06-25 09:37:52 +02:00

Windows string types

The windows-strings crate provides common Windows string types used by various Windows APIs.

Start by adding the following to your Cargo.toml file:

[dependencies.windows-strings]
version = "0.1"

Use the Windows string types as needed:

use windows_strings::*;

const A: PCSTR = s!("ansi");
const W: PCWSTR = w!("wide");

fn main() -> Result<()> {
    let b = BSTR::from("bstr");
    let h = HSTRING::from("hstring");

    assert_eq!(b, "bstr");
    assert_eq!(h, "hstring");

    assert_eq!(unsafe { A.to_string()? }, "ansi");
    assert_eq!(unsafe { W.to_string()? }, "wide");

    Ok(())
}