1pub mod detection;
14pub mod target;
15
16#[cfg(feature = "nightly")]
17pub mod simd;
18
19pub use detection::{cpu_count, detect_host_architecture_only, detect_host_os};
21pub use target::{HOST_ARCH_LIST, Target, TargetArchitecture, TargetOperatingSystem};
22
23#[allow(deprecated)]
25pub use detection::detect_host_architecture;
26
27#[cfg(feature = "nightly")]
28pub use simd::{ArmSimdExtension, RiscvSimdExtension, SimdCapabilities, X86SimdExtension};
29
30#[cfg(test)]
31mod tests {
32 #![allow(clippy::expect_used)]
33
34 use super::*;
35 use std::str::FromStr;
36
37 #[test]
38 fn test_from_str_roundtrip() {
39 let host = Target::detect_host();
40 let str_repr = host.to_str();
41 let parsed_back = Target::from_str(&str_repr).expect("Valid target should parse");
42
43 assert_eq!(
44 host, parsed_back,
45 "from_str/to_str should be a roundtrip operation"
46 );
47 }
48
49 #[test]
50 fn test_detect_functions_consistency() {
51 let combined = Target::detect_host();
53 let arch_str = detect_host_architecture_only();
54 let os_str = detect_host_os();
55
56 assert_eq!(
57 combined.architecture,
58 TargetArchitecture::from_str(arch_str).unwrap_or(TargetArchitecture::Unknown)
59 );
60 assert_eq!(
61 combined.operating_system,
62 TargetOperatingSystem::from_str(os_str).unwrap_or(TargetOperatingSystem::Unknown)
63 );
64 }
65
66 #[cfg(feature = "nightly")]
67 #[test]
68 fn test_target_simd_capabilities() {
69 let target = Target::detect_host();
70 let caps = target.simd_capabilities();
71 assert!(caps.max_vector_width >= 0);
73 }
74}