pub fn msvc_static_crt_subdir(target_features: &str) -> &'static str {
let crt_static = target_features
.split(',')
.any(|feature| feature == "crt-static");
if crt_static {
"static-crt"
} else {
"dynamic-crt"
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn default_is_dynamic_crt() {
assert_eq!(msvc_static_crt_subdir(""), "dynamic-crt");
assert_eq!(msvc_static_crt_subdir("fxsr,sse,sse2"), "dynamic-crt");
}
#[test]
fn static_crt_when_feature_present() {
assert_eq!(msvc_static_crt_subdir("crt-static"), "static-crt");
assert_eq!(
msvc_static_crt_subdir("fxsr,sse,sse2,crt-static"),
"static-crt",
);
}
#[test]
fn does_not_match_substring() {
assert_eq!(msvc_static_crt_subdir("crt-static-foo"), "dynamic-crt");
}
}