summaryrefslogtreecommitdiffstats
path: root/vendor/xflags/examples/non-utf8.rs
blob: d355b24f62decc04d5ded5183b49aa52a1834ed4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
use std::ffi::OsString;

mod flags {
    use std::{ffi::OsString, path::PathBuf};

    xflags::xflags! {
        cmd Cmd
            required a: OsString
            required b: PathBuf
            required c: String
        {
        }
    }
}

#[cfg(unix)]
fn main() {
    use std::os::unix::ffi::OsStringExt;

    let flags = flags::Cmd::from_vec(vec![
        OsString::from_vec(vec![254].into()),
        OsString::from_vec(vec![255].into()),
        "utf8".into(),
    ]);

    eprintln!("flags = {:?}", flags);
}

#[cfg(windows)]
fn main() {
    use std::os::windows::ffi::OsStringExt;

    let flags = flags::Cmd::from_vec(vec![
        OsString::from_wide(&[0xD800]),
        OsString::from_wide(&[0xDC00]),
        "utf8".into(),
    ]);

    eprintln!("flags = {:?}", flags);
}

#[cfg(not(any(unix, windows)))]
fn main() {}