pmeunier / carnix

crate-type is now a Vec instead of an Option

By blabla on October 26, 2018
This patch is not signed.
B6pcjqgTivGbcdeKy9RsBv7BLSCjVfX2Xy1EBwWABq1fXrhkEyEbNQAGXHbpz6iAqPunMpro7RKzVcMz3NcVMEMu
This patch is in the following branches:
master
In file Cargo.lock

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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80

81
82
version = "0.8.11"
[[package]]
name = "aho-corasick"
version = "0.6.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
 "memchr 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "ansi_term"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
 "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "argon2rs"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
 "blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
 "scoped_threadpool 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "arrayvec"
version = "0.4.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
 "nodrop 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "atty"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
 "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
 "termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
 "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "backtrace"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
 "backtrace-sys 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)",
 "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
 "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
 "rustc-demangle 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
 "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "backtrace-sys"
version = "0.1.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
 "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)",
 "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "bitflags"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "blake2-rfc"
version = "0.2.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
 "arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
 "constant_time_eq 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "carnix"
version = "0.8.10"
version = "0.9.6"
dependencies = [
In file Cargo.toml

1
2

3
4
version = "0.8.11"
[package]
name = "carnix"
version = "0.8.10"
version = "0.9.7"
authors = ["pe@pijul.org <pe@pijul.org>"]
In file src/krate.rs
28
29

30
31
    pub proc_macro: bool,
    pub plugin: bool,
    pub crate_type: Option<String>,
    pub crate_type: Vec<String>,
    pub default_features: Vec<String>,
1103
1104


1105
1106
1107
1108
1109
1110
1111
            writeln!(w, "{}  plugin = {};", indent, meta.plugin)?;
        }
        if let Some(ref t) = meta.crate_type {
            writeln!(w, "{}  type = {};", indent, t)?;
        if !meta.crate_type.is_empty() {
            write!(w, "{}  type = [ ", indent)?;
            for t in &meta.crate_type {
                write!(w, "{} ", t)?;
            }
            writeln!(w, "];")?;
        }
251
252

253
254
255
256
257
258



259
260
261
262
263
264
265

266
267
}

fn crate_type(v: &BTreeMap<String, toml::Value>) -> Option<String> {
fn crate_type(v: &BTreeMap<String, toml::Value>) -> Vec<String> {
    if let Some(crate_file) = v.get("lib") {
        if let Some(crate_file) = crate_file.as_table() {
            if let Some(crate_type) = crate_file.get("crate-type") {
                debug!("crate_type = {:?}", crate_type);
                if let Some(s) = crate_type.as_str() {
                    return Some(s.to_string())
                } else if let Some(s) = crate_type.as_array().and_then(|x| x.get(0)) {
                    return Some(s.to_string())
                    return vec![s.to_string()]
                } else if let Some(s) = crate_type.as_array() {
                    return s.into_iter().map(|x| x.to_string()).collect()
                }
            }
        }
    }
    None
    Vec::new()
}