pub mod detection;
pub mod target;
#[cfg(feature = "nightly")]
pub mod simd;
pub use detection::{cpu_count, detect_host_architecture_only, detect_host_os};
pub use target::{HOST_ARCH_LIST, Target, TargetArchitecture, TargetOperatingSystem};
#[allow(deprecated)]
pub use detection::detect_host_architecture;
#[cfg(feature = "nightly")]
pub use simd::{ArmSimdExtension, RiscvSimdExtension, SimdCapabilities, X86SimdExtension};
#[cfg(test)]
mod tests {
#![allow(clippy::expect_used)]
use super::*;
use std::str::FromStr;
#[test]
fn test_from_str_roundtrip() {
let host = Target::detect_host();
let str_repr = host.to_str();
let parsed_back = Target::from_str(&str_repr).expect("Valid target should parse");
assert_eq!(
host, parsed_back,
"from_str/to_str should be a roundtrip operation"
);
}
#[test]
fn test_detect_functions_consistency() {
let combined = Target::detect_host();
let arch_str = detect_host_architecture_only();
let os_str = detect_host_os();
assert_eq!(
combined.architecture,
TargetArchitecture::from_str(arch_str).unwrap_or(TargetArchitecture::Unknown)
);
assert_eq!(
combined.operating_system,
TargetOperatingSystem::from_str(os_str).unwrap_or(TargetOperatingSystem::Unknown)
);
}
#[cfg(feature = "nightly")]
#[test]
fn test_target_simd_capabilities() {
let target = Target::detect_host();
let caps = target.simd_capabilities();
assert!(caps.max_vector_width >= 0);
}
}